Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: A-Hed on Sun 05/02/2006 00:42:39

Title: Label function not working
Post by: A-Hed on Sun 05/02/2006 00:42:39
Ok, what I want is to make the script for a label that works like the @OVERHOTSPOT@ and Iv'e run into a problem.

(http://www.xtreem.nu/jonas/error.png)

I get the error when I put this script in the repeatedly_execute section:

function repeatedly_execute() {
  // put anything you want to happen every game cycle here
  if (Game.GetLocationName(mouse.x, mouse.y) != "") {
    Names_Label.Text = Game.GetLocationName(mouse.x, mouse.y);
  }
  if (Game.GetLocationName(mouse.x, mouse.y) == "") {
    Names_Label.Text = "Nothing of interest";
  }
}


Is there a work around or am I just not clever enough? :P Im not a scripter, so please reply as simple as possible. ;)

Thanks!

/A-Hed
Title: Re: Label function not working
Post by: monkey0506 on Sun 05/02/2006 01:46:13
Just a silly sort of question...but what version of AGS are you actually using?

Also, it's kind of odd that you have used 'if (... != "")' and then 'if (... == "")'.  Might I suggest usage of the keyword, else?

function repeatedly_execute() {
  // put anything you want to happen every game cycle here
  if (Game.GetLocationName(mouse.x, mouse.y) != "")
    Names_Label.Text = Game.GetLocationName(mouse.x, mouse.y);
  else Names_Label.Text = "Nothing of interest";
}


Plus, brackets are only necessary around blocks of code.  Seeing as you only have one line to execute for each statement (the if and the else statements respectively) the brackets aren't necessary.  But, you said you're not a scripter, so it's okay....:D