Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Valentine on Mon 26/01/2009 17:28:58

Title: Two Strings, One Message
Post by: Valentine on Mon 26/01/2009 17:28:58
I'm trying to use DrawStringWrapped to display a message, but I'm having problems. I'm currently using;

surface.DrawStringWrapped(50, 50, 700, 1, eAlignCentre, "%s talks to %s.", Name1, Name2);

but that returns the error 'Error (line 184): wrong number of parameters in call to 'DrawingSurface::DrawStringWrapped'

The code DOES however work for Display, when I used; Display("%s talks to %s.", Name1, Name2);}

The manual says "You can insert the value of variables into the message. For more information, see the string formatting section." so I would have thought they would have worked the same way.

What am I doing wrong? Thanks!
Title: Re: Two Strings, One Message
Post by: Akatosh on Mon 26/01/2009 17:40:33
Some commands don't support formatted strings like that. What you're looking for is something like


surface.DrawStringWrapped(50, 50, 700, 1, eAlignCentre, String.Format("%s talks to %s.", Name1, Name2));
Title: Re: Two Strings, One Message
Post by: monkey0506 on Mon 26/01/2009 17:45:18
Just to be clear, unless the manual entry specifically states that the function supports string formatting, you'll need to use String.Format.

Also, in the calltip prompt which lists all the parameters, these functions (which support string formatting) have an additional parameter listed as "...".