Help with using a text/alphabetical code to unlock a hidden exit?

Hello! First post here. About a year ago I created my first Inform 7 game. It was really quite basic and didn’t have much except the bare minimum to get a feel for the language. I came back to it to give it a more solid ending. So far, I’m not having any luck after multiple attempts.

The basic idea is the player has found a ‘secret’ room. In the room is a pedestal with a button on it. Once the button is pressed the secret combination lock is revealed. If the player inputs the right combination “kzwyw” then they would be able to then see that the secret exit out of the dungeon was unlocked and they completed the puzzle/game.

Here’s the current code I have going:

Section 10 - Secret Room

The secret room is a room.

The description of Secret Room is "You are in awe of the secret room. It is glittering and shining. It's magical. In the middle of the room there is a gold pedastal. On top of it is an ancient scroll that emenates power."

A luminescent scroll is a note. A gold pedastal is a supporter. The luminescent scroll is on the gold pedastal. Gold pedastal is in the Secret Room. A Lock is here. The Lock is a locked container. The Lock is hidden.  Understand "letters" as the Lock.

Carry out reading luminescent scroll:
	say "Congrats on finding the poorly hidden secret room. Thank you for playing my game! I hope you were able to piece together the clues. Since you're in the secret passage, and I don't want this to be TOO HARD/Long, use the acronyms to piece together the order the letters should go in; acronyms are based on room names..... Good luck and thanks again!";
	now the noun is read;

A button is a kind of thing. A button can be pressed or unpressed. A button is usually unpressed.

Pressing is an action applying to one thing. Understand "press [thing]" and "push [thing]" as pressing. Instead of pressing something that is not a button, say "You can't press that."

Carry out pressing a button (called button):
	if the button is unpressed:
		now the button is pressed;
		say "You press the button. A secret compartment on the gold pedestal rotates showing a row of scrambled letters.";
	if the button is pressed:
		now the Lock is visible;
	otherwise:
		now the button is unpressed;
		say "You press the button again and the letters are once again hidden."
		
Golden button is a button. The golden button is under the Gold Pedastal.

The secret exit is a hidden door. The secret exit is north of the field and south of the secret room. The secret exit is locked.

Spinning it to is an action applying to one thing and one number. Check spinning it to: if the noun is not the Lock, say "[The noun] does not spin." instead. Report spinning it to: say "Click! and nothing else happens."

Understand "spin [something] to [text]" as spinning it to.

After spinning the closed Lock to : 
	now the Lock is open; 
	now the Secret Exit is unlocked;
	say "Click! and the safe door swings slowly open, revealing."

The error I get back is:

Problem. You wrote 'now the Lock is visible'  : but this is not something I can make true with 'now', because it is too vague about the underlying cause which would need to be arranged.

 See the manual: 8.11 > 8.11. Now...

Other code I have tried is here:


[There is a lock in the gold pedestal. The lock has some a text called the letters. The description of the lock is "There are five different spaces to place letters.".

The lock has a text called code. When play begins, now the code of the lock is "kzwyw".  Understand "letters" as the lock.

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

Check typing on it:
	if the noun is not the lock:
		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 text understood is the code of the lock:
		now the secret exit 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."

After examining the lock:
	say "The letters are able to be changed. You are ready to enter the password you deciphered throughout the dungeon.";
	continue the action.]
	
[After reading a command when the command prompt is "The letters are able to be changed. You are ready to enter the password you deciphered throughout the dungeon.":
	if the player's command matches "kzwyw": 
		now the secret exit is unlocked;
		say "A loud grinding noise echoes throughout the chamber. You see sunligh beginning to peak through the rocks. You have unlocked the secret exit!";
	otherwise:
		say "The code is incorrect.";
		now the command prompt is "Maybe you should try again.";
	reject the player's command.	
	
After reading a command when the command prompt is "Maybe you should try again.":
	if the player's command matches "try again" or the player's command matches "reenter": 
		now the command prompt is "The letters are able to be changed. You are ready to enter the password you deciphered throughout the dungeon.";
		say line break;
		say run paragraph on;
		reject the player's command;
	if the player's command matches "no" or the player's command matches "n": 
		now the command prompt is "You decide to try again later";
		say line break;
		say run paragraph on;
		reject the player's command;
	otherwise:
		say line break;
		say run paragraph on;
		reject the player's command.]

Sorry, I know this is quite a long bit of jumbled code. Thank you for any help you can offer! If I have to go back and edit the combination into being numbers, that wouldn’t be great, but it would probably solve the problem since there are plenty of examples with number codes. Anyway, if there is a way to do it with a letter code that would be awesome and I’d appreciate your help in teaching me what to do.

1 Like

I haven’t completely looked into your first code, but the reason you’re getting the compilation error is the use of “Now the lock is visible” (as the error message says). “Visible” is a built-in word that determines whether the player can see something–which involves a lot of calculations involving light, opaque containers, etc. So you can’t just set it, because there are lots of ways for it to happen. It’d be like saying “Now X is greater than 5” where X is a variable–you can check whether X is greater than 5, but that doesn’t give enough information to say what X should be.

Anyway, it looks like you’re using “visible” to contrast with “hidden.” If you’ve already got some code dealing with “hidden,” you might just need to define a different adjective, or say “not hidden.”

Another possibility–if the player can’t interact with the lock at all until the button is pressed, a customary way to do that is to start the lock off-stage (just say “There is a lock” and it will be created but not placed in a room) and then, when the player presses the button, have the line “Now the lock is in the secret room” or “now the lock is part of the pedestal” or whatever.

About the text entry code: The way to do that is to define the action as applying to “a topic” rather than a number. So:

Spinning it to is an action applying to one thing and one topic.

Then the text that is entered would be defined as “the topic understood” rather than “the text understood.” Or you could probably do it directly like this:

After spinning the closed Lock to "kzwyw":

Hope this is helpful!

(BTW, check your spelling of “pedestal”–it can be frustrating for players to deal with misspelled objects.)

3 Likes

There’s already a standard action “setting it to” which is defined this way, so you probably want to rely on that rather than creating a new action. Then you can define “spin” to refer to that action if you want.

Similarly, there’s a standard “pushing” action, so you don’t need to define “pressing”.

3 Likes

Thank you SO MUCH! Very helpful. And yes, I realized it was spelled incorrectly as I was posting this haha, will definitely be changing it! Will update if I can’t figure it out still, but this was a really helpful explanation and I think I’ll get it working now thanks to you :slight_smile:

Also, if you look at the Inform IDE there is a tab called “Index”. One of the sub-tabs under that is “Actions” this lists all of the pre-made actions, together with the exact words that trigger them. (It’s automatically updated, so if you make changes to the game, the changes will be reflected there.)

For example, “Push” generates the pushing action, while “hit” generates the attacking action. So you might want to divert Attack into Pushing where your button is concerned.

(I’m sorry I can’t post the code to do this: I’m using a friends pc and so don’t have Inform on it. Likewise I hope I’ve remembered it accurately! )

4 Likes

Thanks again for the help, I’ve gotten the game running again at least. I thought I had it figured out, but now I’m stuck again.

Basically when the button is pressed it doesn’t actually reveal the lock/letters, and when the lock/letters are spun they do not reveal/open the exit even though I have those conditions outlined in the code. I’m not sure how to proceed.

Section 10 - Secret Room

The secret room is a room.

The description of Secret Room is "You are in awe of the secret room. It is glittering and shining. It's magical. In the middle of the room there is a gold pedestal. On top of it is an ancient scroll that emenates power."

A luminescent scroll is a note. A gold pedestal is a supporter. The luminescent scroll is on the gold pedestal. Gold pedestal is in the Secret Room. The Lock is a locked device. The lock can be locked or unlocked. The lock can be hidden or revealed. The lock is part of the gold pedestal. The Lock is hidden.  Understand "letters" as the Lock.

Carry out reading luminescent scroll:
	say "Congrats on finding the poorly hidden secret room. Thank you for playing my game! I hope you were able to piece together the clues. Since you're in the secret passage, and I don't want this to be TOO HARD/Long, use the acronyms to piece together the order the letters should go in; acronyms are based on room names..... Good luck and thanks again!";
	now the noun is read;

A button is a kind of thing. A button can be pressed or unpressed. A button is usually unpressed.

Pressing is an action applying to one thing. Understand "press [thing]" and "push [thing]" as pressing. Instead of pressing something that is not a button, say "You can't press that."

Carry out pressing a button (called button):
	if the button is unpressed:
		now the button is pressed;
		say "You press the button. A secret compartment on the gold pedestal rotates showing a row of scrambled letters. You should spin them into the correct code!";
	if the button is pressed:
		now the Lock is revealed;
	otherwise:
		now the button is unpressed;
		say "You press the button again and the letters are once again hidden."
		
Golden button is a button. The golden button is under the Gold Pedestal.


The secret exit is a hidden door. The secret exit is north of the field and south of the secret room. The secret exit is locked.

Spinning it to is an action applying to one thing and one topic. Check spinning it to: if the noun is not the Lock, say "[The noun] does not spin." instead. Report spinning it to: say "Click! and nothing else happens."

Understand "spin [something] to [text]" as spinning it to.

After spinning the locked Lock to "kzwyw":
	now the Lock is unlocked; 
	now the Secret Exit is unlocked;
	now the Secret Exit is revealed;
	now the Secret Exit is open;
	say "A loud grinding noise echoes throughout the chamber. You see sunligh beginning to peak through the rocks. You have unlocked the secret exit!"

Here’s the playthrough; note, the secret passage is different from the secret exit:

Secret Room
You are in awe of the secret room. It is glittering and shining. It's magical. In the middle of the room there is a gold pedastal. On top of it is an ancient scroll that emenates power.

You can see a secret passage and a gold pedastal (on which is a luminescent scroll) here.

>look under pedastal
You find Golden button!

>press button
You press the button. A secret compartment on the gold pedestal rotates showing a row of scrambled letters. You should spin them into the correct code!

>examine pedastal
On the gold pedastal is a luminescent scroll.

>spin letters to kzwyw
A loud grinding noise echoes throughout the chamber. You see sunligh beginning to peak through the rocks. You have unlocked the secret exit!

>look
Secret Room
You are in awe of the secret room. It is glittering and shining. It's magical. In the middle of the room there is a gold pedastal. On top of it is an ancient scroll that emenates power.

You can see a secret passage and a gold pedastal (on which is a luminescent scroll) here.

>south
You can't go that way.

>open secret exit
I only understood you as far as wanting to open the secret passage.

Thanks again!

Edit: Also Inform won’t let me end the game for some reason? It says it doesn’t understand the verb. Not sure what to add to the beginning of the game where the parameters are set to allow the game to be ended? I thought it was built in. I say “End the game” or end the story and it says it doesn’t understand, so that’s a bit concerning.

Edit 2: Figured out the ending thing. I guess I technically don’t need the exit door to open if I just end the game there when the code is entered. I’m good with that. So, now, I just am still trying to get the combination lock to actually show itself when the button is pressed.

Edit 3: I just kept it where it didn’t actually reveal itself but was still usable. Released it on itch.io privately to share with friends and see what they think. That presented a whole other list of issues, but that’s for another thread tomorrow maybe! Thanks for the help!