SayAt with included Variable SOLVED

Started by Le Woltaire, Mon 02/06/2008 22:23:08

Previous topic - Next topic

Le Woltaire

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.



monkey0506

#1
You're trying to use string formatting which Character.SayAt doesn't support. Instead you can simply pass String.Format as the parameter:

Code: ags
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.

Le Woltaire




SMF spam blocked by CleanTalk