Okay, with a little help from Mike Tarbert, I managed to work this out. I reversed the table so that the actions are in a list, and then reversed the Instead rule. Here’s a complete short game that tests it. The handcuffs required a bit of handholding (if you see what I mean), because Inform stupidly won’t let something be lockable unless it’s a door or a container.
[code]A restraint is a kind of thing. A restraint is usually wearable. The blindfold, the gag, the ball-and-chain, and some handcuffs are restraints.
Instead of doing something when the player wears a restraint:
repeat through the Table of Restricted Movements:
if the player wears the restraint entry:
let impulses be a list of action-names;
let impulses be the movement entry;
if the action-name part of the current action is listed in impulses:
say “You have no hope of [the current action] while wearing [the restraint entry].” instead;
continue the action.
The handcuffs can be locked or unlocked. The handcuffs are locked. The small iron key unlocks the handcuffs.
Instead of locking the handcuffs with the small iron key:
if the handcuffs are locked:
say “They’re already locked.”;
otherwise if the player does not carry the small iron key:
say “You don’t seem to have the key.”;
otherwise:
now the handcuffs are locked;
say “You lock the handcuffs with the small iron key.”
Instead of taking off the handcuffs:
if the handcuffs are locked:
say “The handcuffs seem to be locked.”;
otherwise:
now the player carries the handcuffs;
say “You remove the handcuffs.”
Instead of wearing the handcuffs:
if the handcuffs are worn:
say “You’re already wearing the handcuffs.”;
otherwise if the handcuffs are locked:
say “You’ll need to unlock the handcuffs before you can put them on.”;
otherwise:
now the player wears the handcuffs;
say “You put on the handcuffs.”
Instead of unlocking the handcuffs with the small iron key:
if the handcuffs are unlocked:
say “But they’re not locked!”;
otherwise if the player does not carry the small iron key:
say “You don’t seem to have the key.”;
otherwise:
now the handcuffs are unlocked;
say “It’s awkward, but you manage to insert the key in the keyhole and turn it. Now the handcuffs are unlocked.”
Instead of taking the small iron key when the player wears the handcuffs:
now the player carries the small iron key;
say “You manage to pick up the key, even though you’re wearing handcuffs.”
The Dungeon is a room. “A dank and dismal dungeon. You can go north.”
The Dismal Crypt is north of the Dungeon. “The walls of the crypt are oozing…”
The player wears the ball-and-chain and the handcuffs.
The tool chest is an openable container in the Dungeon. The tool chest is closed. The blindfold and gag are in the tool chest. The small iron key is in the tool chest.
Dave is a man in the Dungeon.
Table of Restricted Movements
restraint movement
ball-and-chain {going action, jumping action, entering action, exiting action, getting off action, climbing action}
gag {eating action, kissing action, answering it that action, telling it about action, asking it about action, asking it for action, saying yes action, saying no action, tasting action, saying sorry action, singing action}
handcuffs {taking action, removing it from action, taking off action, dropping action, putting it on action, inserting it into action, searching action, touching action, waving action, pulling action, pushing action, turning action, squeezing action, eating action, consulting it about action, locking it with action, unlocking it with action, switching on action, switching off action, closing action, wearing action, attacking action, showing it to action, throwing it at action, cutting action, tying it to action, drinking action, swinging action, rubbing action, setting it to action}
blindfold {looking action, searching action, examining action}
Test me with “n / remove ball-and-chain / remove handcuffs / open chest / unlock handcuffs with key / remove handcuffs / remove ball-and-chain / n”.[/code]
You’ll note that the opening action is specifically not included in the list of actions in the table that corresponds to the handcuffs. Opening the chest could, instead, be handled specifically. Feel free to play around with this and let me know if there are problems with it!
–JA