Please login or register.

Login with username, password and session length
Advanced search  

News:

This forum provides RSS feed. To query recent posts use this url. More...


Author Topic: Overriding Talk Method  (Read 5264 times)

0 Members and 1 Guest are viewing this topic.

Tal

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 17
    • View Profile
Overriding Talk Method
« on: September 30, 2008, 01:34:58 AM »

Hey, I'm having trouble overriding the Talk method properly. I need to create a speech bubble over characters' heads, and I'm definitely missing something in the process.

So.

Here's what I've got right now.

My speech window (Not actually a bubble right now, just trying to get a box behind the text) is loaded in game.script as such:

Code: [Select]
global Display = Game.LoadWindow("ui_elements\BUBBLE.window");
Display.Visible = false;


I have a script called Display.script, shown below.

Code: [Select]
global Display;

method DisplayText(Text, Duration)
{
  this.Visible = true;
  // query the static control
  var St = this.GetControl("Texty");
 
  // set the text and wait
  St.Text = Text;

  St.HeightToFit();
  St.SizeToFit();
 
 
  Sleep(Duration);
 
  // hide the text after the "Duration" period has passed
  St.Text = "";
 
  this.Visible = false;
}

"Texty" is the name of the Static Control in the window.


I then am trying to call the script in an actor named Felix; here's his script.
I'm including the Display script at the beginning of his file, then attempting to use the DisplayText method.

When I do, I get a message that I'm calling undefined methods with GetControl and both ToFits.

Code: [Select]
#include "scripts\base.inc"
#include "scripts\keys.inc"
#include "actors\Felix\Display.script"



////////////////////////////////////////////////////////////////////////////////
on "LookAt"
{
 
 Benny.Talk("It's Felix.");
 Felix.TalkAsync("I'M FELIX!");

}


////////////////////////////////////////////////////////////////////////////////
on "Take"
{
   Benny.Talk("I can't take Felix!");
}


////////////////////////////////////////////////////////////////////////////////
on "Talk"
{



Felix.DisplayText("Hey, Benny.");

}
////////////////////////////////////////////////////////////////////////////////



Alright. So. I know this is a mess; can anyone help me sort this out and figure out how to get a working dialog box overriding the normal Talk function?

Thanks in advance.
Logged

metamorphium

  • Global Moderator
  • Addicted to WME forum
  • *
  • Karma: 12
  • Offline Offline
  • Gender: Male
  • Posts: 1511
  • Vampires!
    • View Profile
    • CBE  software s.r.o.
Re: Overriding Talk Method
« Reply #1 on: September 30, 2008, 07:09:53 AM »

replace this with Display and it should work. "This" in this case belongs to actor and not to your method.
Logged
J.U.L.I.A. Enhanced Edition, Vampires!, J.U.L.I.A., J.U.L.I.A. Untold, Ghost in the Sheet

Tal

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 17
    • View Profile
Re: Overriding Talk Method
« Reply #2 on: October 02, 2008, 02:59:59 AM »

Super! It seems to work, basic as it is. Thank you so much!

My next question: I now have this custom DisplayText I'm using over my Talk method. How do I tell that method whose Talk animation to use?

For instance, inside the DisplayText, I need to tell the character to use a blank Talk function, so their mouth moves. How do I define within that script whose mouth should be moving?
Logged

metamorphium

  • Global Moderator
  • Addicted to WME forum
  • *
  • Karma: 12
  • Offline Offline
  • Gender: Male
  • Posts: 1511
  • Vampires!
    • View Profile
    • CBE  software s.r.o.
Re: Overriding Talk Method
« Reply #3 on: October 02, 2008, 07:35:01 AM »

I still am really not sure, you're choosing the wise path doing so. You'd get some serious troubles when you want to include for example voiceovers.

Normal way how to do this override is open the script of your actor and by specifying new Talk method which takes use of the old one (animation, auto voiceovers, text skipping).

method Talk(someText)
{

    // some code to display the caption window belongs here
    ....

    this.Talk(someText); // call the game talk method
   // some code to hide the caption window
    ...
   ....
}

if you want to do this your way, you'd have to use PlayAnimAsync method of your actor and stop that animation as soon as the window closes.
Logged
J.U.L.I.A. Enhanced Edition, Vampires!, J.U.L.I.A., J.U.L.I.A. Untold, Ghost in the Sheet

Tal

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 17
    • View Profile
Re: Overriding Talk Method
« Reply #4 on: October 03, 2008, 01:05:44 PM »

OK, let me try and follow you here, my programming skills aren't great but I'm getting better.

So. Instead of defining the method in a separate script and then having that link over to my actor, I should define the method in the actor itself?
Then, instead of sending the text to the box through Display.GetControl, I'd just be using the regular Talk method and defining the box around it?

I did finally get the box to display on my old code, but the window wouldn't adapt to the size of the text.

Sorry I can't try this out fully at the moment, I have class but I'll be working on it late tonight and most of Sunday.
Logged

metamorphium

  • Global Moderator
  • Addicted to WME forum
  • *
  • Karma: 12
  • Offline Offline
  • Gender: Male
  • Posts: 1511
  • Vampires!
    • View Profile
    • CBE  software s.r.o.
Re: Overriding Talk Method
« Reply #5 on: October 03, 2008, 06:59:46 PM »

I wrote something about this already here:

http://forum.dead-code.org/index.php?topic=3033.0

Maybe you could be inspired there.
Logged
J.U.L.I.A. Enhanced Edition, Vampires!, J.U.L.I.A., J.U.L.I.A. Untold, Ghost in the Sheet

Tal

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 17
    • View Profile
Re: Overriding Talk Method
« Reply #6 on: October 03, 2008, 11:01:48 PM »

EDIT: Progress, progress. Again! I'm on a roll.

Got the box to float above a character's head and contain the text properly, but there are still three core things that bug me. First, when at the full left or right of a screen the text will remain fully on the screen; the window won't.

Second, I still didn't find a way to determine which character is speaking from within the custom method script; I'm temporarily building separate talk method scripts for each character, because it tracks their position through Benny.X and such rather than using a variable to determine who should be speaking.

The third is that the box still doesn't fit to the size of the text.

Code: [Select]
ethod Talk(Text, SoundFilename, Duration, TalkStances, TextAlignment)
{
Game.Interactive = false;
global WinWindow;
global WinSubtitles;
var Static;



WinWindow = Game.LoadWindow("interface\BUBBLE\BUBBLE.window");
WinSubtitles = Game.CreateWindow("subtitles_window"); // position the subtitles window
WinWindow.X = actor.X - 200;
WinWindow.Y = actor.Y - 400;
WinWindow.Width = 400;
//~ WinSubtitles.Height = 300;
WinSubtitles.Visible = true;


// position of actors' speech subtitles
this.SubtitlesPosX = actor.X;
this.SubtitlesPosY = actor.Y - 400;
this.SubtitlesPosRelative = false;
this.SubtitlesWidth = 380;

Yeh. So. I'll update if I get further tonight.
« Last Edit: October 04, 2008, 07:41:18 AM by Tal »
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Overriding Talk Method
« Reply #7 on: October 04, 2008, 02:50:57 PM »

Second, I still didn't find a way to determine which character is speaking from within the custom method script; I'm temporarily building separate talk method scripts for each character, because it tracks their position through Benny.X and such rather than using a variable to determine who should be speaking.
In your custom method, "this" contains reference to the actor speaking.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

Tal

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 17
    • View Profile
Re: Overriding Talk Method
« Reply #8 on: October 04, 2008, 03:36:47 PM »

Yeeeeah, I'm pretty sure I tried that, but it wasn't positioning properly.

I'll try it again when I'm back at a Windows computer to be sure, though.

Doing animations now!

EDIT:

Wow. That worked. Thanks! I think I had tried using this.whatever instead of Benny.whatever before I fixed some of the other problems in my code.

That takes care of the second; still don't know what to do about the first (text stays onscreen, bubble doesn't, screws up positioning), and the I got a temporary solution for by using a lines-measuring code like in your GITS window, but in my case I don't think it's going to help that much.
« Last Edit: October 04, 2008, 09:27:15 PM by Tal »
Logged
 

Page created in 0.043 seconds with 20 queries.