SOLVED: undefined Hotspot error

Started by barefoot, Tue 01/02/2011 19:29:02

Previous topic - Next topic

barefoot

Hi

ide like to know why

Code: ags

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

I May Not Be Perfect but I Have A Big Heart ..

Khris

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:

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

barefoot

Cheers Khris

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

cheers Khris

barefoot
I May Not Be Perfect but I Have A Big Heart ..

Khris

As long as it works... :)
But it's exactly the same situation with objects.

SMF spam blocked by CleanTalk