Label function not working

Started by A-Hed, Sun 05/02/2006 00:42:39

Previous topic - Next topic

A-Hed

Ok, what I want is to make the script for a label that works like the @OVERHOTSPOT@ and Iv'e run into a problem.



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

Code: ags
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

monkey0506

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?

Code: ags
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

SMF spam blocked by CleanTalk