Code to unscrew a hook

In my PunyInform game the player needs to unscrew a hook from a door. So I first created a Global variable “HookGot” which is set true when the hook is unscrewed. But when I compile the game it says “No …Sub” routine for unscrew. Also testing the game itself just gives the message that nothing unusual happens.

This is the basic code I am using. How do I get it to work?

after [; Unscrew:
		if (HookGot == false) {
            move Hook to player;
			HookGot = true;
            print_ret "^You manage to unscrew the hook with a few turns.";

If you’re using the default grammar, ‘unscrew’ is a synonym of ‘turn’, and “unscrew hook” triggers the Turn action.

(See PunyInform/grammar.h at master · johanberntsson/PunyInform · GitHub )

If you want to make sure the player has typed ‘unscrew’ and not ‘screw’ or ‘turn’, you can either:

  • Change your after routine to trigger on the Turn action, but check the word used (verb_word)
  • Create your own Unscrew action and change the grammar for the ‘unscrew’ verb to use that.

For the latter solution, use Extend only, and possibly with replace, i.e.

Extend only 'unscrew' replace
  * noun -> Unscrew;

  "What's the point?";

See DM4 §30: How verbs are parsed for a discussion on Extend only and replace.