Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Chicky on Sat 14/08/2004 14:15:01

Title: need help with string buffer
Post by: Chicky on Sat 14/08/2004 14:15:01
hello there

having a little problem scripting GuardDuty. Im not too experienced with strings and buffers and whatnot.

this is in my GUI script:

else if (button == 0)    // Eat item?
   
    string buffer;
      GetInvName(game.inv_activated,buffer);     
      DisplaySpeech(EGO, "Are you sure you want to eat %s ?",buffer);

i get "error: unexpected string"

a little help please?


*edit*

ok, so I'm still confused. Changed the script a little

    else if (button == 0)    // Eat item?
   
      GetInvName (int item, string buffer);
      GetInvName(game.inv_activated ,item);     
      DisplaySpeech(EGO, "Are you sure you want to eat %s ?" ,item);

: Parse error in expr near "string"

I'm not all that sure what I'm doing. Just trying different things until it works :/
Title: Re: need help with string buffer
Post by: strazer on Sat 14/08/2004 15:12:15
string buffer; // declare variable buffer
GetInvName(game.inv_activated, buffer); // copy item description to variable buffer
DisplaySpeech(EGO, "Are you sure you want to eat %s ?", buffer); // display buffer
Title: Re: need help with string buffer
Post by: Chicky on Sat 14/08/2004 15:21:28
Thanks for the reply strazer, but...
 

else if (button == 0)    // eat item?
      string buffer; // declare variable buffer
    GetInvName(game.inv_activated, buffer); // copy item description to variable buffer
    DisplaySpeech(EGO, "Are you sure you want to eat %s ?", buffer); // display buffer
    GUIOn (EAT);


it still isnt working :/  (unexpected string) Thats the new script.


and here is the eat gui script (not finished, but should work). Its right down the bottom of my gui script.

   if (interface == EAT) {
           
      SetDefaultCursor();
     
    if (button == 0) {
      // They pressed the YES button, eat current item
      GUIOff (EAT);
     
    if (button == 1) {
      // They pressed the NO button, close the GUI
      GUIOff (EAT);
   }

i dont think that would make much difference.
Title: Re: need help with string buffer
Post by: strazer on Sat 14/08/2004 16:05:05
Check your braces:

  else if (button == 0) { // eat item?
    string buffer; // declare variable buffer
    GetInvName(game.inv_activated, buffer); // copy item description to variable buffer
    DisplaySpeech(EGO, "Are you sure you want to eat %s ?", buffer); // display buffer
    GUIOn(EAT);
  }

and

  if (interface == EAT) {
    SetDefaultCursor();
    if (button == 0) { // They pressed the YES button, eat current item
      // eat action here
      GUIOff (EAT);
    }     
    if (button == 1) { // They pressed the NO button, close the GUI
      GUIOff (EAT);
    }
  }
Title: Re: need help with string buffer
Post by: Chicky on Sat 14/08/2004 16:11:27
Thankyou, it is working now