Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Monsieur OUXX on Mon 24/06/2013 19:37:01

Title: [SOLVED] Why won't this dialog script compile?
Post by: Monsieur OUXX on Mon 24/06/2013 19:37:01
It's probably obvious but I don't understand why this script (appearing in a dialog) throws the error : "Dialog 7(84): Script commands can only be used in the area between a @ entry point and the closing return/stop statement"

Code (AGS) Select


@5  // Listen carefully, all of you...
Indy: The subject will be...

  //did we already resolve this?
  if (DialogsLogic.GetVar(eDialog_FoundProperSubject))  {
Indy: ...wood carving...
Indy: ...artwork...
Indy: ...constantinople...
Indy: ...Mehmet IIs reign.
goto-dialog 10 //dStudent2_HowAbout3. That will compute the outcome 
return
  }  /////////// THAT LINE THROWS THE ERROR /////////////////////
  else
  {
goto-dialog 9 //dStudent2_HowAbout2
return
  }
 
return




Because of that error, I get another error "Dialog 8(1): Error (line 1): Nested functions not supported (you may have forgotten a closing brace)" in the dialog immediately after. But I suppose it's only a side-effect.

If I remove the bit I quoted just above, then the code compiles fine.
Title: Re: Why won't this dialog script compile?
Post by: monkey0506 on Mon 24/06/2013 20:09:41
The "return" statements you have after "goto-dialog" are redundant and should be removed. However, the "goto-dialog" statements count as a "return/stop statement", so you can't have any script command (including braces) on the line following that command. So, without having tested it myself, could you use the normal scripting command Dialog.Start instead of calling goto-dialog? Would it have the same result, and create the same branching (e.g., would goto-previous still work?)?
Title: Re: Why won't this dialog script compile?
Post by: Monsieur OUXX on Mon 24/06/2013 20:17:12
Quote from: monkey_05_06 on Mon 24/06/2013 20:09:41
The "return" statements you have after "goto-dialog" are redundant and should be removed.

Yes, I know, I added them in a desperate attempt to trick the compiler.

Quote from: monkey_05_06 on Mon 24/06/2013 20:09:41
However, the "goto-dialog" statements count as a "return/stop statement", so you can't have any script command (including braces) on the line following that command.
Ok. But I need to launch either one dialog or the other depending on the boolean test.


Quote from: monkey_05_06 on Mon 24/06/2013 20:09:41
could you use the normal scripting command Dialog.Start
Let me try that. The compiler is accepting it but I need to test in-game that it doesn't make it explode.
Title: Re: Why won't this dialog script compile?
Post by: Monsieur OUXX on Mon 24/06/2013 21:01:56
It's working! Thanks.