Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Le Woltaire on Mon 02/06/2008 22:23:08

Title: SayAt with included Variable SOLVED
Post by: Le Woltaire on Mon 02/06/2008 22:23:08
Hi,

This doesn't seem to work.


player.SayAt(160, 210, 320, "I have %d Dollars left.", dollars);


I get a  "wrong number of parameters..." output.
It works with the command "Say", but I could need it with the command SayAt...
Is it me, or is it a command structure that isn't included in AGS.
Title: Re: SayAt with included Variable
Post by: monkey0506 on Mon 02/06/2008 22:39:12
You're trying to use string formatting which Character.SayAt doesn't support. Instead you can simply pass String.Format as the parameter:

player.SayAt(160, 210, 320, String.Format("I have %d Dollars left.", dollars));

If you read the manual it will tell you if you can use string formatting directly as parameters to the function itself:

QuoteYou can insert the value of variables into the message. For more information, see the string formatting section.

Otherwise you can simply use the String.Format function as the parameter and build the String that way.

String.Format does the same thing as functions like Display and Character.Say when inserting the value of variables, just instead of using the formatted String to display text it returns the String so you can use it however you'd like. This is especially useful for functions that don't accept string formatting as parameters since you can just pass String.Format as the parameter and achieve the same result.
Title: Re: SayAt with included Variable SOLVED
Post by: Le Woltaire on Mon 02/06/2008 22:45:49
OK, Great.
That's it.