Having trouble with a Keypad lock, Inform7

#1

Hello. I’m trying to make a safe with a keypad lock, i.e, you type “type 73836 on safe” and then the safe is unlocked. My code compiles but does not work as expected. It seems to have no idea what I mean by “the noun” in my if clauses, “type 73836 on safe” produces “You don’t know how to do that to nothing.” If anyone can point out any particular mistakes, I’d be grateful.

Your Bedroom is a room.
In Your Bedroom is a safe.   It is a closed, locked, opaque container.   The safe is scenery.
The description of the safe is "It's a small safe, about a cubic foot, with a keypad on the front, laid out the same as a cellphone keypad."
The safe has a number called the combo. When play begins, now the combo of the safe is 73836.  Understand "keypad" as the safe.

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

Check typing on it:
	if the noun is not the safe:
		instead say "You don't know how to do that to [the noun].";
	if the noun is unlocked:
		instead say "[The noun] is already unlocked."
	
Carry out typing on it:
	if the number understood is the combo of the noun:
		now the noun is unlocked;
	
Report typing on it:
	if the noun is unlocked:
		say "The lock clicks unlocked.";
	otherwise:
		say "You type the number on the keypad, but nothing happens."
0 Likes

(matt w) #2

All you need to do is to change “noun” to “second noun” throughout. Even though there’s technically only one noun, it gets stored as the second noun because it’s in the second place in the grammar line.

(I don’t know if this is written down anywhere, I just found it by experimenting.)

0 Likes

#3

Ah, thank you! I’ve been working on this problem for an embarrassing amount of time, the existence of “second noun” explains a lot of the errors I encountered.

I made the substitution and everything works as it should.

0 Likes