I wrote a bit of example code that was designed to put a cap on the number of times you guessed a verb – but it has a bug, which I’ll describe below.
The idea is that, if there’s a certain action that the player is supposed to perform with an object, after a certain number of attempts the game will just perform the action – even if the player has been entering non-standard verbs that would ordinarily get an “I don’t know how to do that” response. You can think of it as, if the PC struggles with the object enough, eventually they’ll accidentally perform the right action.
It has a bug I can’t quite figure out, though, as you can see if you try “Test weird” on the code below. The game is supposed to print a message and end in victory once you try “Throttle thingummy” for the third time, but instead it prints a message and gives you a command prompt; then ends the game in victory as soon as you enter the next command. Any idea what’s going on here? If it’s something that only happens when you’re ending the game in victory, that’d be easy to work around, but if it arises with other activities that could be very bad.
Anyway, code follows:
[code]
“Fiddle.”
The Bare Room is a room. “No apparent exit, nothing here but a thingummy sticking out of the floor.” The thingummy is scenery in the Bare Room. “It must have some purpose, but you can’t tell what to do to it.” The thingummy is fixed in place.
Twisting is an action applying to one thing. Understand “twist” as twisting.
Instead of twisting:
If the noun is the thingummy:
say “The thingummy twists around and locks into place with a loud click. You see the wall slide open and beyond it, sweet freedom.”;
end the game in victory;
otherwise:
say “That can’t be twisted.”
Instead of turning the thingummy:
try twisting the thingummy.
The fiddle-count is a number which varies. The fiddle-count is usually 0.
Rule for printing a parser error when parser error is not a verb I recognise:
if the player’s command includes “[thingummy]”:
say “You struggle with the [thingummy].”;
try fiddling with the thingummy;
otherwise:
say “I’m not sure how to do that.”
Before doing something other than turning or twisting or examining or fiddling with to the thingummy:
say “You struggle with the thingummy.”;
try fiddling with the thingummy;
stop the action.
Fiddling with is an action applying to one thing.
Instead of fiddling with the thingummy:
increase the fiddle-count by 1;
if the fiddle-count is 3:
try twisting the thingummy;
stop the action;
otherwise:
say “It wiggles provocatively but doesn’t move in any productive way.”;
stop the action.
Counting is an action applying to nothing. Understand “count” as counting.
Carry out counting:
say “The fiddle-count is [the fiddle-count].”
Test me with “throttle thingummy/ count/ ride it/ count/ take it”.
Test weird with “take thingummy/ count/ ride it/ count/ throttle it/ look”.
test normal with “twist thingummy”.[/code]
Of course, you should feel free to use this code if it’s helpful and not irrevocably bugged. You could also use it for evil, by making fiddling result in failure – “The thingummy breaks off in your hand. Guess you should’ve read the manual before starting to fiddle with it.” But that would be evil.