How to make a "SayAt" function.

Started by LRH, Sat 18/02/2012 20:20:04

Previous topic - Next topic

LRH

I have a quick question about making something relatively simple. Somehow, I'm having a difficult time grasping it.

This is basically what I want to accomplish:

All of the characters in the game I'm working on are to "SayAt" all dialogue in a dialogue box on the bottom of the screen. Since the X, Y, and length values will never change, it would be a pain to keep typing out the command for each character. Is there a way I can make my own function like cEgo.SayBox("etc."); so that I don't have to keep using the SayAt function?

Thank you in advance for any and all help!


Ryan Timothy B

Yep, look up  Extender functions  in the manual.
Only issue is that the Auto-Number Speech Lines for easily getting all dialogue scripts and adding voice for them won't work with an extender function.

LRH

Yeah, I'm kinda hitting a theory wall here. I looked up extender functions but I still don't really understand how to accomplish what I'm going for.

I'm screwing around with:

Code: ags


function Box(this Character*)
{
this.SayAt(etc.etc.""); 
}



But then I would need to make a function for each line of dialogue, wouldn't I? I'm sorry I'm not too quick on the uptake here...

Ryan Timothy B

You're almost there..

Code: ags
function Box(this Character*, string Message)
{
  this.SayAt(x, y, width, Message); 
}

With x, y, and width obviously needing to be replaced with static values for your purpose.

LRH

Quote from: Ryan Timothy on Sat 18/02/2012 21:39:42
You're almost there..

Code: ags
function Box(this Character*, string Message)
{
  this.SayAt(x, y, width, Message); 
}

With x, y, and width obviously needing to be replaced with static values for your purpose.

Ah! Okay, thanks! That's very helpful!

Ryan Timothy B

Actually there is one way you could go about cheating the system so that you could still get Auto-Number Speech Lines to still work and that is by using Define. But only useful if you were actually using the speech system, otherwise I'd just stick with using the extender method.

Code: ags

//put this in the header of the global script
#define BoxValues 10, 10, 100 

player.SayAt(BoxValues, "Test");

The Define will actually change BoxValues to:  10, 10, 100   during compile time.
So it actually works like this:  player.SayAt(10, 10, 100, "Test");

SMF spam blocked by CleanTalk