EVENT-SCRIPTS
A world event (an invasion, a festival) is written in DeadScript in a room's boot script. Scenario.define() declares it; that room is its home, and the functions of the room's script are its hooks. The game keeps the event's state in a file of its own, so it carries on after a reboot. (DeadScript's Event is its timers, so the class is called Scenario.)
rb room javascript boot .
function raidTurn() {
var e = Scenario.current;
e.count( 'turns' );
}
function raidStart() {
Scenario.current.every( 40, 'raidWave' );
}
function raidWave() { ... }
Scenario.define( { id: 'olden-road-raid', title: 'Raiders on the Olden Road',
areas: [ 'Mozartia' ], ends: '2026-12-01',
knobs: { raid_size: { def: 5, min: 3, max: 8 } },
budget: { stepsPerTurn: 1500 },
onTurn: 'raidTurn', onStart: 'raidStart', onEnd: 'raidEnd' } );
/s
| Plan field | Meaning |
| id | lower-case letters, digits and -, at most 31; required |
| title | for immortals and the digest |
| areas | the zones (names) it may narrate to and count players in, at most 8 |
| starts, ends | dates, '2026-11-15' or '2026-11-15 14:00' (UTC): it can't start before starts and ends at ends |
| knobs | its dials (see EVENT-DIALS) |
| budget | its limits (see EVENT-BUDGET) |
| onTurn | a hook run every turn (7.5 seconds) while it runs |
| onStart, onEnd | hooks run once when it starts and when it ends |
A new event is a draft: it does nothing until an immortal types event start (see EVENT-COMMAND). Defining it again (the next boot, rspawn boot) reads the plan again and keeps its state.
Channel lines said while a hook runs (a mob's act( 'gossip ...' ) in onStart, say) are the event's, and the channel history keeps them, unlike what mobs say by themselves (see CHAT-HISTORY). Outside the hooks, a mob's script marks a line to keep with keepNextChannelLine() (see JS-CHAR).
In a hook, Scenario.current is the event; anywhere, Scenario.get( 'id' ) finds one (or null). An event has id, title, state, turn (turns it has run), phase and home, and these methods:
| Method | Does |
| knob( name ), setKnob( name, value ) | a dial (see EVENT-DIALS) |
| count( key [, n] ), set( key, n ), get( key ), log( code [, text] ) | its counters and log (see EVENT-LOG) |
| after, every, at, cancel | tasks for later (see EVENT-TASKS) |
| narrate( scope, [target,] text ) | a line to a room, a zone, its areas or the world (see EVENT-NARRATE) |
| present( [zone] ) | who is there (see EVENT-PRESENT) |
| setPhase( name ) | names the stage it is in (raids, siege); shown in its status and digest |
| end( [reason] ) | ends it for good |
Remember: in DeadScript undefined == null is false. Use ?? for a value that may be missing. get() gives 0 for a counter never set.