Reading values
Paths and readers that give you a number or a name: $.subject, $.stat(), $.field().
These give you a value to compare, add up, or pass to a step.
Stats: by role, not by name
$.stat('might')
Stats are read by role. A game can call its strength stat "Might", "Brawn" or "Thew", and
$.stat('might') reads it in all three. Reading by display name ($.stat('brawn')) breaks the
day someone renames it.
$.stat(key) answers:
healthandplayerLevel;- each stat key the game declares (
strength,agility, or whatever it has); - each role that one of the game's stats claims, from the engine's
might,resolve,presence,speed,evasion,accuracyandinsight, and any role a plugin declares (also by its full id,engine:speed). A stat named the same as a role wins that name.
So $.stat('speed') in a game whose stats are strength and agility reads agility, if agility
claims speed. A role no stat claims has no value, and neither does any other name. The formula
fails and a gate reading it stays shut (see Missing values). The stats editor shows
which stat claims each role, and get_plugin lists what every key reads in this game.
5 + $.stat('might') * 1.5 // a heavy weapon that hits harder in strong hands
Fields
A field is a value a plugin declared on something: satiety, infection, mana.
$.field('satiety') // on the subject
$.field('satiety', 'player') // on the host player
$.field('infection', 'target') // on whoever was aimed at
$.field('corruption', 'location') // on the place itself
A field that no entity has reads null, not 0. That difference decides whether your rule fires.
See Missing values.
Carried totals
$.carried('weight')
Adds up a field across everything the subject holds. This is how encumbrance works.
Dials: your tuning numbers
$.dial('foodDrainPerHour')
Reads one of your plugin's dials, the numbers an author can tune in your plugin's panel.
Never copy a dial's value into your code as a number. 0.4 works until someone changes the
dial, and then two numbers disagree and nothing errors. See Formulas and dials.
Tables: your plugin's own rows
When your plugin owns a list (tiers, a roster, a matchup chart), declare a table and read it
through $:
$.table('conditions') // every row, as an array
$.row('conditions', 'snow') // the row whose first column is 'snow', or null
$.row('conditions', 'snow').tempBand // one cell
A misspelled table name reads as an empty table. A loop over it will silently never execute.
Table or field?
- A field lives on the entity and is edited on that entity's sheet. A location added later gets it automatically. Use it when the value belongs to the thing.
- A table lives in your plugin's panel. A location added later is missing from it until someone adds a row. Use it for your system's vocabulary.
Whichever you pick, read from where you wrote. Filling in a table and then reading
$.location.fields.something gives you a system that's fully set up but never runs.
Time
$.event.minutes // how long this stretch took
$.timed // whether the world has a clock
In a game without a clock, minutes is the narrator's guess and swings from 3 to 22 for
similar turns. Price by the hour only when there's a real clock:
$.timed ? $.dial('drainPerHour') * ($.event.minutes / 60) : $.dial('drainPerTurn')
See Minutes are not time.
Everything you can read
| Path | Answers |
|---|---|
$.subject |
The entity this rule is about. |
$.subject.name |
The subject's name. |
$.subject.kind |
What the subject is: 'player', 'npc', 'creature' or 'object'. |
$.subject.location |
Where the subject is. |
$.subject.health |
Current health. |
$.subject.maxHealth |
Maximum health. |
$.subject.dead |
Whether the subject is dead. |
$.subject.level |
The subject's character level. |
$.subject.fields |
The subject's declared fields, by key. |
$.subject.bonds |
The subject's NPC bonds. |
$.subject.home |
An NPC subject's authored home location ('' when they have none); absent on anyone else. |
$.subject.heading |
Where a creature subject is walking. That is the place $.headTo sent it, else its next patrol stop, or '' when neither. Absent on anyone else. |
$.subject.equipSlots |
Equipment slots an item subject can occupy (empty array for non-equippable items); absent on living entities. |
$.subject.isWeapon |
Whether an item subject can occupy a weapon slot (by role, even if renamed); absent on living entities. |
$.subject.isEquipment |
Whether an item subject can be equipped in any slot; absent on living entities. |
$.source |
Who caused it - attacker, user, emitter. |
$.source.weapon |
What the source wields, shaped like $.weapon. In onAttack the subject is the target, so you read an attacker's ammunition here with $.source.weapon.fields.loaded. |
$.player |
The acting player: whoever uses the item or casts, or the subject when it is a player, else the host. Use $.party for everyone. |
$.player.name |
The acting player's name: whoever uses the item or casts, the host when nobody in particular acts. |
$.player.health |
The acting player's health. |
$.player.level |
The acting player's character level. |
$.player.fields |
The acting player's declared fields. |
$.party |
Every player - host and guests. |
$.location |
The place this is happening in. Printing it gives the name, so "at " + $.location still reads as the place. |
$.location.name |
The place's name. |
$.location.fields |
Declared number fields on the current place by key, covering anything with trait "location". Untouched places read empty, not as zero. |
$.location.tags |
The place's declared text fields, by key. |
$.world |
World flags. |
$.here |
What is in the current location. |
$.exits |
Formatted as { name: distance }, listing everywhere you can reach in one hop. Edges work both ways regardless of how they were drawn. Use Object.keys($.exits).length === 0 to test for map edges when running generators. Empty if the game has no map. |
$.items |
All carried items, mapped as name to quantity. Use this when inspecting names dynamically. Object.keys($.items) lists them, and $.items["Rope"] returns how many there are. |
$.pack |
Detailed inventory for the subject, with an entry for each carried row: { name, key, fields, tags, quantity }. Use this when specific item instances matter, like finding which magazine holds the most ammo, and target that copy with item: entry.key. |
$.equipped |
What the wearer has in each slot, mapped by the slot names declared in this game. Empty slots return null. If an entity lacks a slot entirely, that key is omitted, so $.slotEmpty is easier than checking for null by hand. |
$.weapon |
The item in the subject's weapon slot, null when unarmed, whatever the game calls that slot. |
$.weapon.name |
The wielded item's name. |
$.weapon.fields |
The wielded item's declared number fields. |
$.weapon.tags |
The wielded item's declared text fields. |
$.weapon.key |
That one wielded item, as a key a field step can write to: $.adjustField({ field: "rounds", by: -1, item: $.weapon.key }). |
$.weapon.ammoLeft |
How many matching rounds the wielder has, whether loose or in an open container. Returns null for weapons that don't use ammo. |
$.weapon.roundsPerShot |
How many rounds one shot spends: 1, or more for a burst or automatic weapon. Null when it fires nothing. |
$.mobs |
Creatures present. |
$.foes |
Who present can still fight the party: creatures that are not companions and have not stood down, and people who turned on it. |
$.game |
Every item, character, location, mob, ability and effect in the game, full authored records included, populated only inside a declared action's afterRoll body. Search it by name: $.game.filter(e => e.name === 'Rusty Key')[0]. Each entry has name, kind, description, mechanics (compiled item rules), quests (an NPC's authored steps), costs (an ability's resource costs), refs (every other name this one references - search every OTHER entry's refs for a name to find what points AT it) and here ("seen" when it is in the acting character's place or carried or held by someone there, "hidden" when it is there but out of sight, "" elsewhere). |
$.turn |
The turn number. |
$.combat.active |
Whether a fight is running right now. |
$.combat.round |
Which round the fight is on, counting from 1. Zero when no fight is running. |
$.combat.allies |
How many on the player's side are still standing. Zero outside a fight. |
$.combat.enemies |
How many on the enemy side are still standing. Zero outside a fight. |
$.quests |
Every quest by name. Each entry includes status ("inactive", "active", "completed" or "failed"), the current step index starting at 0, and total steps. Check completion with status === "completed". A finished quest moves step one past the last index, to equal steps. On an active quest, step === steps - 1 means they're on the final step. |
$.visited |
Names of every location the party has visited. Use $.visited.indexOf($.location) === -1 to check if this is their first visit. |
$.timeMinutes |
Minutes on the world clock. Advances once per tick. |
$.minutesPassed |
Minutes on the world clock since the game began. |
$.minutesPerDay |
Minutes in one day under this world's calendar (Earth: 1440). |
$.timed |
Whether this world has a clock. Charge per hour when true, or per turn when false. In clockless games, $.event.minutes is just the narrator's rough estimate. |
$.setting |
The game's setting. |
$.killCount |
Kills so far. |
$.minted |
What the tool just created, available inside the tool body. Evaluates to {} everywhere else, returning undefined without throwing errors. |
$.minted.name |
The name of the thing just minted. A mint invents the name, so this is the only way a body can place, spawn or grant what it made - $.spawnItem({ itemExpr: $.minted.name }). |
$.event |
The payload from the firing trigger. Evaluates to {} outside hooks, returning undefined without throwing errors. |
$.item |
The item in play. Null outside the item-use path. |
$.item.name |
The item's name. |
$.item.state |
The item's state. |
$.item.fields |
The item's declared fields. |
$.target |
The aimed-at entity. |
$.target.name |
The target's name. |
$.target.state |
The target's state. |
$.target.fields |
The target's declared fields. |
What's on $.event depends on the trigger. See Hooks.