SCRMaps
/
Sign in

eudplib: triggers and control flow

Conditions and actions as function calls, plus if and while.

9 min read

eudplib exposes every condition and action you already know as a function, under nearly the same names. What follows is what sits on top of them: how triggers are built, and the control flow.

Building triggers
Trigger(conditions, actions, preserved)A trigger with conditions and actions. Preserved by default, with no limit on how many of each.
DoActions(actions, preserved)A trigger whose condition is Always - for when you just want something to happen.
PTrigger(players, conditions, actions)Runs only when Current Player is one of the listed players. Pairs naturally with EUDPlayerLoop.
RawTrigger(prevptr, nextptr, conditions, actions)The low-level trigger, with the engine's own limits. It has an address, so its nextptr can be manipulated.
Disabled(arg)Disable a condition or an action.
EPD(p)Convert an offset into its EPD player value.
Condition(...) / Action(...)Build a raw condition or action in CHK layout. Only needed if you know scenario.chk.
The conditions and actions that reach memory
Memory(dest, cmptype, value)Compare the value at an offset. This is where EUD starts.
MemoryEPD(dest, cmptype, value)The same, but dest is an EPD value.
SetMemory(dest, modtype, value)Write to memory.
SetMemoryEPD(dest, modtype, value)Write to memory addressed by EPD.
SetCurrentPlayer(p)Change Current Player. Use this rather than writing 0x6509B0 yourself.
SetNextPtr(trg, dest)Rewrite a trigger's nextptr to change execution order.
Conditionals and loops
EUDIf()(cond) / EUDElseIf()(cond) / EUDElse()() / EUDEndIf()if, else if, else - always closed with EUDEndIf.
EUDIfNot()(cond) / EUDElseIfNot()(cond)The negated forms.
EUDWhile()(cond) / EUDWhileNot()(cond) / EUDEndWhile()A while loop.
EUDLoopN()(count) / EUDEndLoopN()Repeat count times.
EUDInfLoop()() / EUDEndInfLoop()Loop forever.
EUDPlayerLoop()() / EUDEndPlayerLoop()Run once per player in the game, each as Current Player.
EUDExecuteOnce() / EUDEndExecuteOnce()For code that must run exactly once.
EUDSwitch(var) / EUDSwitchCase()(case) / EUDSwitchDefault()() / EUDEndSwitch()Like C's switch, including fall-through if you do not break.
EUDBreak() / EUDBreakIf(c) / EUDBreakIfNot(c)Leave a loop or switch.
EUDContinue() / EUDContinueIf(c) / EUDContinueIfNot(c)Skip to the next iteration.
EUDSetContinuePoint()Set where continue jumps to. One per block.
Jumps
EUDBranch(conditions, ontrue, onfalse)Jump to one of two places depending on a condition.
EUDJump(nextptr)Jump to a destination.
EUDJumpIf(c, ontrue) / EUDJumpIfNot(c, onfalse)Jump when the condition holds.
Loops over the game's own structures
EUDLoopUnit()Walk every unit structure in the game.
EUDLoopBullet()Walk every bullet.
EUDLoopSprite()Walk every sprite.
EUDLoopList(header_offset, break_offset)Walk a doubly linked list.
EUDLoopRange(start, end)Iterate a numeric range - the better EUDLoopN.
EUDLoopTrigger(player)Walk every TRIG trigger belonging to a player.
Combining conditions
EUDAnd(cond) / EUDOr(cond) / EUDNot(cond)And, or and not over conditions - this is where the OR classic triggers lack comes from.
EUDTernary(conditions, ontrue, onfalse)The ternary operator. Note that both sides are evaluated regardless of the condition.

In epScript you write ordinary if, while and foreach and the compiler turns them into these. The list matters when you write Python directly, or when one of these names turns up in an error.

Sign in to track your progress