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.";
        }
        ];
1 Like

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)
    or
  • 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;

[UnscrewSub;
  "What's the point?";
];

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

1 Like

Hello Chris,

Hope things are going well. May I ask if this game has been released yet?

Thanks,
-Pinkunz

Alas no. I’m working on another game (which I started before this one) which must take priority. To be honest I got burnt out and had to take a long break from coding. At some point soon I hope to return to this game.

1 Like

Happens to the best of us. Good luck with your games and when you’re done, please consider announcing it here and on IFDB.org if you’re willing. We can’t play what we don’t know exists.

1 Like

Hi, the good news is I’ve returned to working on the game. I was hoping to get it ready for the PunyJam 4 competition but there’s just too much work involved. However, I have done a lot of work recently to improve it.

You can follow my progress via screenshots and text over on my X account:

https://x.com/chrishesteruk?t=-Plth9C6Lsm05Z88qg_LGQ&s=09

3 Likes