Having trouble with making a "typing in on" action


In my game, there is a safe. In order to open this safe, you need to type in a 4-digit code on the keypad (which, in order to avoid a much larger problem I was having and to prevent player frustration, is now just another name for the safe). This is the source code for the safe and the “typing in on” action that I am using for this:

The wall safe is a closed locked fixed in place container in Living Room. "A small safe is embedded in the wall, next to the bookshelf." The description of the safe is "Made out of pitch black metal and locked tightly. A keypad rests to the right of the door, with numbers 0 to 9 available to type in. Presumably, if you were to type in a 4-digit code, this safe could open."
Instead of opening the safe when it is locked: say "[if the player knows safe-code]You're going to have to type in the code.[otherwise]It's locked shut. You'll need to find the code in order to open this." Understand "keypad" and "small safe" as the safe.
Typing in on is an action applying to one number and one thing. Understand "type in [number] on [something]" as typing in on.

Check typing in on: if the noun is the wall safe: continue the action; otherwise: say "You mime typing in a code on [the noun]. Mrs. Hart shoots you a confused look. 'Uh... I'm not going to ask.'"

The game doesn’t give me any report when I run the game with this, so I thought this would work fine. But here’s what happens when I try typing the number on the safe:

>type in 1492 on wall safe
You mime typing in a code on nothing. Mrs. Hart shoots you a confused look. "Uh... I'm not going to ask."

I’m unsure on how to approach this and what I’ve read in the documentation hasn’t helped much. Does anyone know what is wrong with my source text and how I can fix it?

I suspect (haven’t tested) that the wall safe is the second noun, not the noun. The number counts as “first” even though it’s not very nouny.


I had thought about that, but had initially dismissed it because the first part wasn’t a noun. Maybe I should’ve tried it anyway. Oops. :grimacing:

Looks like it works fine now, though. Thanks, dude.

A tip for naming actions: For syntax reasons, it’s a good idea to include the word “it” in actions applying to more than one thing, i.e. “typing it in on”. This makes it unambiguous to Inform where the nouns in the action are, and it generally makes rules easier to write. There are ways to write around this, as you already have done, but it’s good practice. Without it, a rule like this won’t compile:

The security code is initially 4634.

Check typing a number (called the PIN) in on the safe (this is the standard security rule):
	if the PIN is the security code:
		continue the action;
		say "You enter [PIN] on the keypad. Nothing happens."

Yeah, was going to reply with the “it” thing – it’s one of the major pieces of unexplained Inform 7 lore, since I don’t think it’s ever really mentioned in the docs, but can really mess you up if you don’t use it (or if you use “it” in an action only taking one noun).

and just for a little less to think about and type, a check action rulebook automatically proceeds through all the rules unless one fails (normally with stop the action or with the instead phrase). So you can skip the continue the action (though it could be useful in a more complicated check rule with nested if-thens).

Typing it on is an action applying to one number and one thing.
Understand "type in/-- [number] on [thing]" as typing it on.

Check typing a number on something (called the peripheral) when the peripheral is not the safe:
  instead say "That wouldn't do much."

Check typing a number (called the PIN) on the safe:
  unless the PIN is the security code, instead say "Nothing happens."

Be cautious with messages like Mrs. Hart shoots you a confused look. 'Uh... I'm not going to ask.'". What if she’s not there? What if you type on yourself? What if you type on Mrs. Hart? (Why, yes, I’m playtesting a game currently.)

The instead can go at the end of a phrase instead (see what I did there?). It may sound stilted as English to put it first following an unless clause, like above, but my habit is always putting it first. (A comment by Zarf on instead placement called my attention to the relevance of having a habit on the subject.)


@BlueAskew & @DeusIrae

Thank you for these tips, that’s really good to know. I’ll try and remember to keep that in mind.


Okay, thank you!

The game just takes place in one room, and just for the moment she is the only person there, so she is most likely to respond. But I do plan on adding at least one more person to the scene, so I will probably add more to that part of the code later.

Some of these situations you’ve proposed would be useful to consider though, so I might have to add some more adaptive text to respond to these scenarios. Thanks!

1 Like

My code will be much cleaner for having learned this. Thank you. I’m not sure if I forgot this or if I never knew it, but it’s useful.

1 Like

Crap. Something went amiss, didn’t it?


side note, typing (actually tapping, Morse code or prearranged signals, often indeed the number of taps…) is a classical silent & discreet communication system; prior of earphones, tapping & gesturing often was the only viable communication system in really noisy environment, like, for example, the engine room of a 1880s-1890s steam ship at flank speed), ex.:


The engineman turn the valve wheel until the gauge reads 143.5 psi.

this is why steamships have engine telegraphs instead of voice tubes between bridge and boilers & engine rooms…

Best regards from Italy,
dott. Piergiorgio.

Like most of these things, you can find it mentioned in the docs if you happen know where to look. It’s near the bottom of 12.7 New actions. [Also relevant is the parenthetical statement in the caveat to the caveat in 17.19 Does the player mean… which says that sometimes the “it” isn’t needed.]

1 Like