Casebier wrote:
So here's a question... why did that extra Wait command make the script pause for 6 turns?
The _MyScriptX variable you used overrode the wait command. My guess is that you would see different wait lengths depending on where in the room you were testing the script, as well as your orientation.
Here are my guidlines for using _MyScript variables:
1) Once you've set a _MyScript variable, use it as soon as possible.
2) Once you've used a _MyScript variable, reset it as soon as possible.
3) Never use _Myscript variables to store data.
Even though it might clutter your code, I would recommend following 1) and 2) strictly. Doing this will ultimately improve readibility and lessen obfuscation. Even if you're being careful with your IF structures, separating the setting and resetting of _MyScript variables can lead to disasterous consequences in the future. If, for example, you return to your script later to extend it in some way and forget how you've managed your _MyScript variables, a simple Goto in your IF blocks that would otherwise make sense can devastate your script. And those sorts of issues can be a nightmare to debug.
Create well-named variables that represent the data you're trying to store, and assign their values to the _MyScript variables as close as possible to the exact moment when they're needed.
Here's a reimagining of your script. This is entirely untested, FYI, so it might break somewhere. But shows how, stylistically, I believe _MyScript variables should be used.
Click here to view the secret text
×Imperative 15
Label loop
Wait for event Player teeters on pit edge
Set var "HorizOffset" = _O % 3 - 1
Set var "VertOffset" = _O / 3 - 1
Set var "XAfterOffset" = _X + HorizOffset
Set var "YAfterOffset" = _Y + VertOffset
If ...
Wait until var "XAfterOffset" < 0
Go to End
If End
If ...
Wait until var "YAfterOffset" < 0
Go to End
If End
If ...
Wait until var "XAfterOffset" > 15
Go to End
If End
If ...
Wait until var "YAfterOffset" > 15
Go to End
If End
Set var "_MyScriptX" = XAfterOffset
Set var "_MyScriptY" = YAfterOffset
If ...
Wait for item Pit,0,0,0,0
Set var "_MyScriptX" = -9999
Set var "_MyScriptY" = -9999
Set var "XAfterOffset" = _X + HorizOffset + HorizOffset
Set var "YAfterOffset" = _X + VertOffset + VertOffset
Else
Set var "_MyScriptX" = -9999
Set var "_MyScriptY" = -9999
Go to End
If End
If ...
Wait until var "XAfterOffset" < 0
Go to End
If End
If ...
Wait until var "YAfterOffset" < 0
Go to End
If End
If ...
Wait until var "XAfterOffset" > 15
Go to End
If End
If ...
Wait until var "YAfterOffset" > 15
Go to End
If End
Set var "_MyScriptX" = XAfterOffset
Set var "_MyScriptY" = YAfterOffset
{Nuntar's code here}
If ...
Wait for entity NPC 0,0,0,0
Go to End
If End
Set var "_MyScriptX" = -9999
Set var "_MyScriptY" = -9999
Set var "_X" = XAfterOffset
Set var "_Y" = YAfterOffset
Label End
Set var "_MyScriptX" = -9999
Set var "_MyScriptY" = -9999
Wait 0
Go to loop
____________________________
http://beepsandbloops.wordpress.com/