Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: LRH on Mon 22/09/2014 01:27:38

Title: [Solved.] Custom function triggering error.
Post by: LRH on Mon 22/09/2014 01:27:38
Situation is this:

I'm making a game which starts as a text adventure and sort of morphs into a graphical adventure.  As such, it would be really nice to have all kind of shortcut functions to throw into the script, as text adventures naturally have many repeating elements.

Global script has this before the game start function:

Code (ags) Select

function repeat1()
  {
    Lbox1.AddItem("");
    aDoorbell.Play(eAudioPriorityHigh, eOnce);
    Lbox1.AddItem("The doorbell rings again.");
    Lbox1.AddItem("What did you do?");
  }



Room code has this:

Code (ags) Select

else if (Parser.Said("look television"))
  {
    Lbox1.Clear();
    Lbox1.AddItem("Your eyes begin to glaze over...");
    repeat1();
  }


Getting undefined token error when trying to call this function in the room. I know this must be something incredibly basic, but I'm completely stumped.  This is the exact syntax I've used in other games without any issue.
Title: Re: Custom function triggering error.
Post by: Crimson Wizard on Mon 22/09/2014 01:35:03
You need to declare the functions you want to use in other modules in the script header:
Code (ags) Select

import function repeat1();
Title: Re: Custom function triggering error.
Post by: LRH on Mon 22/09/2014 02:04:27
*Facepalm* -- of course I do.

Too much Lua, eh? :tongue:

Thank you very much for the help. I appreciate it.