Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Tomatoworm on Mon 14/11/2011 19:10:57

Title: Weird errors in room script
Post by: Tomatoworm on Mon 14/11/2011 19:10:57

The last time I opened my game it seemed to work fine ,but now for some reason I keep on getting errors whenever I try to run it. It is really frustrating, because it seems to choose random lines even if they are correct :-[. Sometimes it even says there is an error on line -10! I tried the game on different computers and reinstalled AGS. Has anyone else had this problem?
Title: Re: Weird errors in room script
Post by: Khris on Mon 14/11/2011 19:59:00
Quote from: Tomatoworm on Mon 14/11/2011 19:10:57even if they are correct

Believe me, they aren't (because if they were, you wouldn't get compiler errors, see?)

Line -10 means you have forgotten a closing quote at the end of a string somewhere.
It's almost always something along the lines of:
  Display("This will throw an error.);

Please post the offending line and surrounding ones next time, and mention the exact error you get (why oh why do we keep having to mention this...?)
And here's the very first result of a forum search for "line -10" in the beginner's tech: http://www.adventuregamestudio.co.uk/yabb/index.php?topic=40671.msg537579#msg537579

Welcome to the forums :)
Title: Re: Weird errors in room script
Post by: Tomatoworm on Tue 15/11/2011 01:18:14
Thank you for the reply! :) Here is the line I've been having trouble with:

function oOpenDoor_Interact()
{
cBert.Walk(171, 240, eBlock, eWalkableAreas);
oOpenDoor.Visible = false;
GiantDoor.Visible = true;
RemoveWalkableArea(2);
RestoreWalkableArea(3);
}

The error says "Nested functions not supported (you may have forgotten a closing brace)". It refers to the top line.
Title: Re: Weird errors in room script
Post by: Gilbert on Tue 15/11/2011 01:23:32
Please post more codes, mainly the part before those you have just posted. It's usually mistakes in the codes above that cause this error.
Title: Re: Weird errors in room script
Post by: Khris on Tue 15/11/2011 01:40:39
Yes, that error suggests you haven't closed the function before the one you posted.
You can see a bracket's counterpart by moving the cursor next to it and pressing Ctrl+B.

I would also recommend you indent your code; if you do this properly from the start you'll save yourself heaps of trouble:

function oOpenDoor_Interact()
{
  cBert.Walk(171, 240, eBlock, eWalkableAreas);
  oOpenDoor.Visible = false;
  GiantDoor.Visible = true;
  RemoveWalkableArea(2);
  RestoreWalkableArea(3);
}
Title: Re: Weird errors in room script
Post by: Tomatoworm on Tue 15/11/2011 02:22:55
I finally got the script to work! You were right the error was in the line above. Thank you for all your help!!  ;D