DisplayAtY question

Started by CaptainD, Tue 19/06/2018 22:12:32

Previous topic - Next topic

CaptainD

Is it not possible to put a variable into a DisplayAtY expression?

Code: ags
DisplayAtY(200, "Cats are on the prowl... they manage to kill %d of your rats", num)
returns the error wrong number of parameters in call to 'DisplayAtY' - it works fine with Display but I want to position the text displayed.  Am I missing something obvious or is it simply a limitation of this particular function?  I can't find anything explicit in the manual about this.
 

Crimson Wizard

Only functions that have "..." in the parameter list may take extra variables to format a string. This is called "variadic function".

Compare:
Code: ags

Display (string message, ...)
DisplayAt(int x, int y, int width, string message, ...)

But
Code: ags

DisplayAtY(int y, string message)



When you need to pass a string somewhere that does not have "...", use String.Format to create a string:
Code: ags

DisplayAtY(200, String.Format("Cats are on the prowl... they manage to kill %d of your rats", num));

CaptainD

Brilliant, thanks so much CW!!
 

SMF spam blocked by CleanTalk