InputBox Trouble (SOLVED)

Started by , Fri 17/02/2006 16:40:57

Previous topic - Next topic

LegosJedi

I try using the script shown here to have the player input his own name for the main character, such as in games like Pokemon and Zelda. I save my changes in the global script, and try to save my changes to the game. It gives me this:

QuoteError (line 6): Parse error: unexpected 'InputBox'

So I try the version from the manual. AGS gives me pretty much the same error. What does this mean? How can I fix this problem?

Dan

Sounds as if you may have missed a semicolon ( ; ) at the end of the previous line.

Also, what version of the editor are you using, as the new version would expect something more like this:

Code: ags

 // Declares a string to store the player's reply
 String buffer;    
 // Asks the player for name   and stores it in "buffer"
 buffer = Game.InputBox("What is your name?");
 // Transfers the content of "buffer" (the name) to player.Name
 player.Name = buffer;  


Note the subtle differences such as String instead of string, etc.

Ashen

Where in the global script have you put it? Line 6 sounds like it would be in game_start, or possibly even before any functions. Try moving it into one of the 'Player enters screen' interactions for the first room ('after fadein' is probably better, but 'before' might work).
(Well done for actually using the BFAQ, though.)
I know what you're thinking ... Don't think that.

LegosJedi

#3
Dan:

No, I didn't miss a semicolon. I jsut copied and pasted.

I tried your thing and it still didn't work. It told me there was an unexpected 'buffer',

I think I'm using version 2.71.

Ashen:

I just went to "edit global script" and put it at the very beginning after the "// main global script file" in line 1.

Quote from: AshenTry moving it into one of the 'Player enters screen' interactions for the first room.

Yeah, let me try that.

EDIT: Just tried that and it worked! Thanks, Dan and Ashen!

Ashen

Looking at it again, I think it would've worked in game_start, but it needed to be inside SOME function. Strings (and strings at V2.7 and earlier) can be declared outside functions, but not changed (in this case, by the InputBox(..) command and player.Name = buffer;).

Also, InputBox(..) can only be called from inside another function - otherwise AGS doesn't know when to run it (this is what caused the "unexpected 'InputBox'" error - it shouldn't have been in that part of the script).
I know what you're thinking ... Don't think that.

SMF spam blocked by CleanTalk