Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Sensei on Thu 26/04/2012 12:18:23

Title: My cXXX_Talk function gone rouge
Post by: Sensei on Thu 26/04/2012 12:18:23
Something is wrong with this script:

function cLoring_Talk()
{
  if (cSydny.Room == 1)
  {
    if (Game.DoOnceOnly ("TalkLoringCell") == true)
    {
      cSydny.Walk (600,  590, eBlock, eWalkableAreas);
      cSydny.FaceCharacter (cLoring, eBlock);
      cLoring.Say (" Dress yourself girl. We havent got all day. ");
      cSydny.Say ("But i wanna kno...");
      cLoring.Say ("You can ask qestions once we get out of here.");
    }
  }
}

Error: Nested functions not supported (You may have forgotten a closing brace)

Can somebody tell me what´s wrong? This script accualy worked already. I´m sure i didn´t make any changes in it, but in one moment ags just started to write this error. Only thing i changed since i tested this script was few changes in other scripts whitch aren´t related with this one.
I´ll be glad for any suggestios how to solve it.
Title: Re: My cXXX_Talk function gone rouge
Post by: Khris on Thu 26/04/2012 12:24:21
If you're getting the "nested functions" error in line X, that means you forgot a closing brace somewhere above line X.

For instance, this:
1  function Hello() {
2    player.Say("Hello!");
3
4
5  function Bye() {
6    player.Say("Bye!");
7  }
will tell you about an error in line 5. (Since in line 5, the function keyword was found, but inside another function.)

To check braces, you can move your cursor directly after one, then hit Ctrl+B and it will show the corresponding one.
Title: Re: My cXXX_Talk function gone rouge
Post by: Sensei on Thu 26/04/2012 12:33:47
Above that line? Good to know. ;)

Got it!
Thanks again.

Title: Re: My cXXX_Talk function gone rouge
Post by: Khris on Thu 26/04/2012 13:08:44
Btw, please use the forum search before opening a thread.
Searching the technical forums for posts with "nested functions" in the subject line yielded lots of relevant hits, including for instance:
http://www.adventuregamestudio.co.uk/yabb/index.php?topic=44387