Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: barefoot on Tue 01/02/2011 19:29:02

Title: SOLVED: undefined Hotspot error
Post by: barefoot on Tue 01/02/2011 19:29:02
Hi

ide like to know why


hHotspot5.Enabled = false;


sometimes comes up with this:


GlobalScript.asc(1462): Error (line 1462): Undefined token 'hHotspot5'

seems i cant use it if used with activeinventory function???

cheers

barefoot

Title: Re: undefined Hotspot error
Post by: Khris on Tue 01/02/2011 19:39:40
That's because you're using the hotspot's name in the global script.
You can only access the current room's hotspots, i.e. if the player is currently in room 2, you can't turn off a hotspot in room 5 (that's because only the current room is loaded into memory and gets unloaded as soon as you leave it).

To access hotspots from the global script you have to use the hotspot array:

  if (player.Room == 2) hotspot[5].Enabled = false;

This will turn off the hotspot with ID number 5 in room 2, but only if the player currently is in room 2.
If you didn't use the if check, the command would turn off the current room's hotspot 5, regardless which room the player is in.

If you actually want to do something to a hotspot in another room, you have to use a variable. You'd create a global one using the Global variables pane and change that, then check the variable's value in the before fadein event of the other room and change the hotspot accordingly.
Title: Re: undefined Hotspot error
Post by: barefoot on Tue 01/02/2011 20:06:58
Cheers Khris

yes, i understand now... i am now using an object instead and that works ok..

cheers Khris

barefoot
Title: Re: SOLVED: undefined Hotspot error
Post by: Khris on Tue 01/02/2011 20:41:52
As long as it works... :)
But it's exactly the same situation with objects.