From 3d7aea9c2df76bad79dfa16b879e9e7195139f39 Mon Sep 17 00:00:00 2001 From: Autumn Valenta Date: Sun, 5 May 2024 22:44:06 -0600 Subject: [PATCH] Add inline actions to objects --- public/world/Terra Montans.txt | 2 +- src/interactions.js | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/public/world/Terra Montans.txt b/public/world/Terra Montans.txt index 261943d..3b9da63 100644 --- a/public/world/Terra Montans.txt +++ b/public/world/Terra Montans.txt @@ -54,5 +54,5 @@ 23,40=25,42:Room 3 25,42=23,40:Tavern 28,36:bed -31,39:bed +31,39:bed#Look=The bed seems nice. 28,42:bed diff --git a/src/interactions.js b/src/interactions.js index ba3b26e..bd49066 100644 --- a/src/interactions.js +++ b/src/interactions.js @@ -13,8 +13,8 @@ const OptionalAttributes = "(?(#[^=]+=[^#]+)*)"; const WORLD_SPEC = RegExp(`^${RowCol}=${NewRowCol}:${Label}/${DataFile}$`); const DOOR_SPEC = RegExp(`^${RowCol}=${NewRowCol}:${Label}${OptionalAttributes}$`); -const NPC_SPEC = RegExp(`^${RowCol}:${Label}/${DataFile}${OptionalInventory}$`); -const OBJ_SPEC = RegExp(`^${RowCol}:${Label}$`); +const NPC_SPEC = RegExp(`^${RowCol}:${Label}/${DataFile}$`); +const OBJ_SPEC = RegExp(`^${RowCol}:${Label}${OptionalInventory}${OptionalAttributes}$`); const TYPE_SPECS = { world: WORLD_SPEC, @@ -145,6 +145,13 @@ function amendWorld(target, { inventory }) { } function amendObj(target, { inventory }) { - target.Inspect = { name: 'Inspect', text: null }; + const { attributes={} } = target; + Object.entries(attributes) + .filter(([name]) => /^[A-Z]/.test(name)) + .map(([name, text]) => { + target[name] = { name, text }; + }) + ; + // target.Inspect = { name: 'Inspect', text: null }; return; }