Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: SadoDeomeoon on Tue 28/06/2016 15:53:41

Title: "if (dExample.GetOptionState(1) = eOptionOff)" is asking for semicolons (SOLVED)
Post by: SadoDeomeoon on Tue 28/06/2016 15:53:41
In an attempt to start a new game, I've encountered a problem. I wanted a dialogue to start when the player first starts the game (which works, dBeginning, in this case) and then after the dialogue is over, make the objects visible (which show instructions.) I decided to use option-off in the dialogue script (since it's fairly easy and I'm still a noob) to turn the 1st option off, then only make the objects visible if it is off, to make sure the dialogue is over.

However, using the code below, all I get is an error saying "Error (line 36): expected semicolon after ')'" Line 36 is line 4 below. No matter how many semi colons (which I don't think I need) I stick into that line of code, I simply cannot get it to work.

What am I doing wrong?

Code (ags) Select

function room_FirstLoad()
{
dBeginning.Start(); // Run the dialogue
if (dBeginning.GetOptionState(1)=eOptionOff) // The line with the error
{
    oRightMouse.Visible=true;// Make all these objects visible
    oWalkCursor.Visible=true;
    oLookCursor.Visible=true;
    oInteractCursor.Visible=true;
    oTalkCursor.Visible=true;
}
}


Edit - Like the idiot I am, I forgot to put a double = in line 4 :grin:
Title: Re: "if (dExample.GetOptionState(1) = eOptionOff)" is asking for semicolons (SOLVED)
Post by: Khris on Wed 29/06/2016 01:46:01
It still won't work though because the dialog is only started after the test in line 4.
The solution is to move the five commands into the dialog script, right before the final "stop" command (and indent them by at least one space).
Title: Re: "if (dExample.GetOptionState(1) = eOptionOff)" is asking for semicolons (SOLVED)
Post by: SadoDeomeoon on Wed 29/06/2016 15:15:14
I worked that out. I'm going to do as you suggest and put it in the dialog script. Is it dialog_request? (Thanks for the reply!)
Title: Re: "if (dExample.GetOptionState(1) = eOptionOff)" is asking for semicolons (SOLVED)
Post by: Khris on Wed 29/06/2016 15:54:30
dialog_request is obsolete, it's what you had to use in older versions of AGS.

You can simply put regular script commands right inside dialog scripts, as long as you indent them by at least one space.
(Basically just do exactly what I told you to do in my previous post.)
Title: Re: "if (dExample.GetOptionState(1) = eOptionOff)" is asking for semicolons (SOLVED)
Post by: Grok on Thu 30/06/2016 05:58:45
In a dialog script I believe you have to refer to an object this way
   
        object[1].Visible=true;


The number (ID) of the object you will find in the property list for that object.
Title: Re: "if (dExample.GetOptionState(1) = eOptionOff)" is asking for semicolons (SOLVED)
Post by: SadoDeomeoon on Thu 30/06/2016 07:53:15
Okay thank you very much!