Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: LRH on Sat 18/02/2012 20:20:04

Title: How to make a "SayAt" function.
Post by: LRH on Sat 18/02/2012 20:20:04
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!

Title: Re: How to make a "SayAt" function.
Post by: Ryan Timothy B on Sat 18/02/2012 20:38:35
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.
Title: Re: How to make a "SayAt" function.
Post by: LRH on Sat 18/02/2012 21:27:04
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:



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...
Title: Re: How to make a "SayAt" function.
Post by: Ryan Timothy B on Sat 18/02/2012 21:39:42
You're almost there..

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.
Title: Re: How to make a "SayAt" function.
Post by: LRH on Sat 18/02/2012 22:37:01
Quote from: Ryan Timothy on Sat 18/02/2012 21:39:42
You're almost there..

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!
Title: Re: How to make a "SayAt" function.
Post by: Ryan Timothy B on Mon 20/02/2012 20:02:48
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.


//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");