Hi
I trying to make my first gui using Ghost tutorial but get a error message: Error (line 60): Undefined token'myCreateScummText'
I have made the function, it was when I put it in the repeatedly execute function it stoped working.
Hope someone understand what Im trying to say and here is the code:
function repeatedly_execute() { // put anything you want to happen every game cycle, even when the game is paused, here
myCreateScummText();
if (IsGamePaused() == 1) return; // put anything you want to happen every game cycle, but not when the game is paused, here
}
function myCreateScummText ()
{
if (mouse.Mode == eModeWalkto) { lblScummText.Text = "walk to";}
if (mouse.Mode == eModeLookat) { lblScummText.Text = "look at";}
if (mouse.Mode == eModePickup) { lblScummText.Text = "take";}
if (mouse.Mode == eModeInteract) { lblScummText.Text = "use";}
if (mouse.Mode == eModeTalkto) { lblScummText.Text = "talk to";}
if (mouse.Mode == eModeUseinv) { lblScummText.Text = "use";
lblScummText.Text = lblScummText.Text.Append(player.ActiveInventory.Name);
if(Game.GetLocationName(mouse.x, mouse.y)!=player.ActiveInventory.Name){
lblScummText.Text=lblScummText.Text.Append("on");
lblScummText.Text=lblScummText.Text.Append(Game.GetLocationName(mouse.x, mouse.y));
}
}
if (mouse.Mode!= eModeUseinv) { lblScummText.Text = lblScummText.Text.Append (Game.GetLocationName(mouse.x, mouse.y));}
}
Did you make sure you put the mrCreateScummText() function before repeatedly_execute in the game's global script?
Thank you! That made it work! ;D
Hooray :D
You´re the best! :D
Aww how cute, lil' Ben teaching people about programming stuff. :=
Just to clarify the reasoning behind it, some languages allow you to forward declare functions (tells the compiler you're going to define function X later on so you can use it now) or even just call functions before their defined without a declaration, but AGS does not. You can only call a function in AGS that has already been defined. So for example:
function func_A() {
func_B();
}
function func_B() {
// ...
}
Will not work in AGS because when it comes to func_A then func_B hasn't yet been defined. However, reversing it such as:
function func_B() {
// ...
}
function func_A() {
func_B();
}
Will work. If you ever find that you need portions of two functions to both call each other, consider splitting those functions into smaller utility functions so they can both call the appropriate bits of code as needed. ;)
Quote from: monkey_05_06 on Sun 27/12/2009 19:22:08
Aww how cute, lil' Ben teaching people about programming stuff. :=
Hee hee I tricked her into thinking I am smart ;D
;D