Manual:DIL Manual/break
Jump to navigation
Jump to search
Contents
break
Instruction. Leaves the loop it is in.
break;
Jumps to the first statement after the innermost while or foreach around it. These are DIL's only loop statements.
Notes
- Outside a loop vmc stops with "Using break outside loop".
- In nested loops it only leaves the innermost one.
- Leaving a
foreachearly is fine: the units it hadn't reached are dropped when the nextforeachstarts or the template returns.
Example
dilbegin wake_sleeper();
var
u : unitptr;
code
{
u := self.outside.inside;
while (u != null)
{
if ((u.type == UNIT_ST_PC) and (u.position == POSITION_SLEEPING))
break;
u := u.next;
}
if (u != null)
exec("wake " + u.name, self);
quit;
}
dilend
An NPC looks through its room for the first sleeping player and wakes them. After the loop u is that player, or null when there was none.