Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: Vel on Thu 04/11/2004 17:27:33

Title: Scripting a function (SOLVED)
Post by: Vel on Thu 04/11/2004 17:27:33
Hey there.
So, I've got this script in the global one:

function DisplaySubtitle(CHARID, string buffer){
   DisplaySpeechAt(160, 235, 320, CHARID, "%s", buffer);
   }

And it gives me an error on the string... I tried some other possibilities but failed to make it work :/ So, any help would be greatly appreciated.
Title: Re: Scripting a function
Post by: Rui 'Trovatore' Pires on Thu 04/11/2004 18:40:35
Why not just DisplaySpeechAt(160, 235, 320, CHARID, buffer); ? I don't think that function supports %s, BTW.
Title: Re: Scripting a function
Post by: Vel on Thu 04/11/2004 19:14:36
Tried that also - buffer not defined.
Title: Re: Scripting a function
Post by: Dave Gilbert on Thu 04/11/2004 19:18:33
Hm, don't know much about this, but are you sure that the string is being transferred to the function correctly?  You might want to try this as a test:

Display("%s", buffer);

The problem could be the string itself.

-Dave
Title: Re: Scripting a function
Post by: Dorcan on Thu 04/11/2004 23:51:28
CHARID is a reserved variable I think.

this one works :

function DisplaySubtitle(int charID, string buffer){
   DisplaySpeechAt(160, 235, 320, charID, buffer);
}
Title: Re: Scripting a function
Post by: stuh505 on Fri 05/11/2004 03:30:34
You never specified the data type for one of the input paramaters of the function
Title: Re: Scripting a function
Post by: Vel on Fri 05/11/2004 09:11:47
Oh I got it Dorcan, thanks a lot!
Title: Re: Scripting a function (SOLVED)
Post by: Pumaman on Fri 05/11/2004 18:17:30
Yes, CHARID is a bit of a confusing one. It is actually a present used internally which defines to "int charid" -- therefore you can use it in the function parmaeter list, but not as a variable in the actual code.

Basically, avoid using it at all.