Manual:DIL Manual/waitnoop
Jump to navigation
Jump to search
Contents
waitnoop
Instruction. Steps out of the current event for a moment.
waitnoop;
The program stops here and runs on almost at once: in the same pass of the game's event queue, after the event that woke it has been dealt with. A follower woken by its master's move (an SFB_DONE event) uses it so that the master's command finishes, and the other programs get the event, before the follower runs a command of its own with exec().
It is written without parentheses: waitnoop(); is a syntax error.
Notes
- Nothing else wakes the program while it waits: no commands, messages or ticks, and no
interrupt()oron_activation()fires. Those events are lost to it, not queued. - Coming back is a wake like any other. Every
unitptrvariable that isn't secured is null afterwards, and activator, argument, cmdstr and the others no longer describe the old event. Copy what you need into variables first. - Secures are tested at the wake. If the command that was running took a secured unit away (a master who walked out, say), the program goes to that secure's label instead.
- Don't use it while a program before this one on the unit (lower fnpri) may hold priority: the wake is then dropped, and the program never runs again.
- basemove.zon (the
followcommand) is the only user in the game.
Example
dilbegin fnpri(FN_PRI_MISSION) tagalong();
var
c : string;
code
{
:start:
wait(SFB_DONE, activator == self.master);
if (command("north") or command("east") or command("south") or
command("west") or command("up") or command("down"))
{
c := cmdstr;
waitnoop;
exec(c, self);
}
goto start;
}
dilend
When its master has moved, the NPC takes the same exit, as dilfollow in basemove.zon does. cmdstr goes into c before the waitnoop, because it describes another event afterwards.