I need help with 'if'

I’m trying to make a thing where if i put a needle inside a small hole, then a door will unlock, and it will display a message saying so. I wrote:

If the needle is in the small hole, say “The back panel clicks and becomes loose.”
(I haven’t included the part that will unlock the door yet)

But it gives me the error message:

You wrote ‘if the needle is in the small hole, say “The back panel clicks and becomes loose.”’ : but this seems to give something a name which contains double-quoted text, which is not allowed.

I’m new to inform, so I have absolutely no idea what’s wrong.

It looks like you haven’t specified an action (or other kind of rule) for your test to apply to. Tests in Inform generally need to be in rules so Inform knows when to run them. Most of these rules pertain to specific actions that the player that the player is performing, or “Every turn” rules that run at the end of the turn after the action has been totally resolved. (There are also other kinds of rules like “When play begins:” and a few others, and there are phrases that you can define that get called from rules… but let’s just stick with action-based ones for now.)

So one thing you could do is–if you have the hole implemented as a container–check every turn to see whether the needle is in the hole.

Every turn: If the needle is in the small hole: say "The back panel clicks and becomes loose."; now the secret door is unlocked.

…or whatever the name of the door is for “secret door.”

However, you probably don’t want this to happen on a delay–you put the needle in the hole and then you get a message about unlocking the door. It seems like you might want to just have that be the result of the command “PUT NEEDLE IN HOLE.” Then you’d hook it to the action that results from that–which is the action of inserting the needle into the small hole. So it might look like this:

Instead of inserting the needle into the small hole: say "The back panel clicks and becomes loose."; now the secret door is unlocked.

And for this, it’d probably be nice to include a message for when the player puts something else in the hole, to demonstrate that the hole isn’t about containing things (and hint what might work):

Instead of inserting the something into the small hole: say "The hole is very small. Only something very thin would fit into it."

These approaches, since they run “Instead” of the inserting action, mean that the needle won’t wind up in the hole but will stay in the player’s inventory–which seems fine! Also, the more specific rule about the needle should run before the less specific one (and then stop processing the action), so the second rule won’t mess up the first.

Hope this helps! There’s a lot more Inform to learn, but this should get you started I hope. And welcome to the forum!

As a tip, if you click the “code” button in the formatting buttons and paste your code in between, you get the code display, which can be especially handy for when you need to share some code that has indentation.

Thank you so much!