I am having a basic scripting problem and wonder if anyone can help.
Problem:
The result I am trying to achieve is this. When the player selects a certain dialog option, an object on the screen (object 0 in the room in question) becomes visible.
The method I am using:
In the Character Interactions tab “Run Script†is selected and the script is…
RunDialog (0);
if (GetGlobalInt (2)==1)
object(0).Visible = true;
By this I am hoping that the dialog will be run and if the correct option has been selected and Globalint 2 has been set to one, the object will become visible after the dialog has finished.
When the dialog option in question is selected in the dialog itself by the player a global variable (number 2) is set to true (1). This is done like this
@2 // option 2
shopkeep: xxxxx xxxxxxx xxxx xxxxxx
Set-Globalint (2) 1
stop
However, the game will not run (test) and the following error message comes up
Compile Error
There was an error compiling your script. The problem was:
In ‘Global Script'
Error (line 142): PE04: parse error at ‘object'
Do you want to fix… etc.
I have been through the manual/knowledge base etc. but can't find an answer. I am fairly new to the scripting part of AGS and so possibly the way I am trying to do it is just plain wrong and I would be grateful for alternative suggestions. I'm not even sure i am using the object/visibility command correctly but can't work it out from the manual etc.
I do however want the object to be turned on directly from the dialog and not from a subsequent interaction.
Any help gratefully received!
Is that code exactly as it is in your game? If so:
object(0).Visible = true;
Should be:
object[0].Visible = true;
Note the square brackets around the 0.
However, because of the way RunDialog works, that still won't do what you want (it's queued until other code is finished - so the GlobalInt check will be run BEFORE the dialog, not after). Read the BFAQ (http://americangirlscouts.org/agswiki/Scripting%2C_Code_%26_Interaction#Running_regular_code_inside_dialog), and/or do a forum search for dialog_request for a better way to handle it.
Ahhh, I hadn't noticed the square brackets thing!
Thanks for the help, I had seen the dialog_request thing in the manual but didn't quite understand it. That section in the BFAQ and the explanation about the run dialog queueing has cleared it all up now!
Cheers.