Spot Indepedence

When writing scripts that reference spots most people write them with the specific spot numbers imbedded in the script. This works great in the room the scripts were written for but if a spot becomes corrupted and has to be replaced or if the scripts are placed in a new room with new spots they typically will not work.

The following are suggestions for writing scripts so they are spot independent - that is, they will work in any spot.

 

When writing scripts that reference the spot they're in use 'ME' instead of the specific spot number.

Assume that the following commands are in spot number 5:

1 5 SETSPOTSTATE - change spot 5 to state 1

1 ME SETSPOTSTATE - change the spot it's in to state 1

These do the same thing but if installed in another spot the first command won't work without being changed to the new spot number whereas the second command will work no matter what the spot number is.

 

When writing scripts that reference another spot use a variable name instead of the specific spot number and set the variable name in the referenced spot.

1. Assume the following command is in some spot other than 5:

100 5 SETALARM - set spot 5 alarm to go off in 100 ticks

and the following is in spot 5:

ON ALARM ... - whatever the alarm handler is.

2. Assume the following commands are in some spot other than 5:

spotname GLOBAL

100 spotname SETALARM - set spot with number equal to 'spotname' alarm to go off in 100 ticks

and the following is in spot 5:

ON ENTER { spotname GLOBAL ME spotname = } - set variable 'spotname' to the number of the spot which contains the command (in this case to 5)

ON ALARM ... - whatever the alarm handler is.

These do the same thing but if the script in spot 5 is installed in another spot the first command won't work without being changed to the new spot number whereas the second commands will work no matter what the spot number is.