I try using the script shown here (http://americangirlscouts.org/agswiki/index.php/Graphics%2C_Characters%2C_Text_%26_Rooms#Naming_your_character_and_using_that_name_throughout_the_game) 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?
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:
// 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.
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.)
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!
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).