I am creating a (hopefully) simple semi-autowalk script for Achaea. When I'm already familiar with an area, and just want to quickly go from point A to point B, entering a series of commands is nice. So far, my alias executes my series of movement commands precisely, in a for loop.
I'm running into a snag while trying to ensure that doors are handled properly. Rather, I don't want doors to be handled at all - I want the path to terminate if a door is in the way. If the path continues after it fails to move because of a door, I end up in the wrong place. If there is a door, I don't want it to open automatically. If I did, I would have put "open door" in my path.
What I would like to do is run my script with a pause after moving, which allows the MUD to catch up to me and allows a trigger to set a variable if it finds a door, then at the end of my script reset the variable so paths will work next time. So, C's sleep() or #wait in Nexus.
Here's the crux of the problem: tempTimer(sec,script) executes a script after a set number of seconds, completely independently of the rest of the script. It won't pause my script. tempTimer() is great for some things, but not great for what I'm trying to do.
What is the normal way to handle this kind of thing? Has anyone else had a similar issue?
One solution I did come up with was this:
This does wait a half a second, doing nothing else. It's taking advantage of the global scope of variables.
It's also incredibly inefficient, because the script continues to run even when we are intentionally doing nothing. It polls the timer variable until the tempTimer has executed (thus setting the variable), and just because Lua won't let you have an empty block, we even needed to assign a pointless variable to waste cycles.
I was hoping to find a much more efficient method than this. The best one, by far, would be a simple wait method that doesn't allow further execution until the time is up.