Working With...Area Events
Area events are snippets of text that can be set to print on every turn, or random turns, or every x number of turns. They are intended to provide ambient texture.
MyGame.createAsset({
class: "Room",
name: "Southern Dunes",
area_events: [
"Sands shift beneath your feet. ",
"A brief dry breeze does nothing to cool you. ",
"Heat haze shimmers over distant dunes. ",
],
});
Zone Area Events
Rooms can subscribe to zone area events, allowing multiple rooms in a region to share common events.
MyGame.createAsset({
class: "Room",
name: "Southern Dunes",
zone: "Desert Zone"
});
MyGame.createAsset({
class: "Room",
name: "Northern Dunes",
zone: "Desert Zone"
});
MyGame.createAsset({
class: "Zone",
name: "Desert Zone",
area_events: [
"Sands shift beneath your feet. ",
"A brief dry breeze does nothing to cool you. ",
"Heat haze shimmers over distant dunes. ",
],
});
String Array Function
Area events are subject to String Array Function, which means they can be set to provide dynamic results. For instance, if you had a day/night cycle, you might set a function to print a different set of events during day and night.
MyGame.createAsset({
class: "Room",
name: "Southern Dunes",
area_events: function(){
if( MyGame.getVar(is_night) ) { // using a world variable
return A.FX.pickRandom([ // utility method for randomizing an array from within a function
`An incredible tapestry of stars flares overhead. `,
`A meteor streaks across the sky. `,
`Moonlight shimmers across the dunes. `,
]);
}
else {
return A.FX.pickRandom([
`The blazing sun bakes the desert floor. `,
`Heat haze shimmers across the dunes. `,
`Random grains of sand sparkle with reflected sunlight. `,
]);
}
},
});
When providing an array to String Array Function, it's possible to apply more granular control over the frequency and order of events.
MyGame.createAsset({
class: "Zone",
name: "Desert Zone",
area_events: {
frequency: 0.1, // infrequently
randomize: true, // vs each in order
array: [
"Sands shift beneath your feet. ",
"A brief dry breeze does nothing to cool you. ",
"Heat haze shimmers over distant dunes. ",
],
},
});
Enable / Disable
Area events can be enabled and disabled during gameplay by setting
game.settings.enable_area_events, which means that you can turn
them on and off in response to other game states.
MyGame.settings.set({
enable_area_events: true,
});
Further Reference
- Working with Area Scenery
- Working with Area Zones
- enable_area_events in Settings
- Basic Scripting: String Array Function in Author's Manual
- Room class in Reference Manual
- Zone class in Reference Manual