I7: Temporarily blocking an exit

Hi, everyone. This is my first piece of IF, and I’m having trouble doing something that doesn’t seem like it should be all that complicated. Basically I have a room, the Seaboard, with an exit going east. I want the player to be blocked from going east unless they are wearing a bracer. I can’t get the code to work properly. It either won’t compile or the player is blocked from going east on the entire map or even when wearing the bracer, he can’t go east in the Seaboard.

I’m working withBefore going east: If the player is in the Seaboard: unless the player is wearing the bracer: Instead of going east: say "Brecca laughs, 'You're not serious, are you?'"

This will compile, but it prevents the player from going east at all.

Thanks! I really appreciate any advice.

Try something like this:

Instead of going east when the player is in the Seaboard:
If the player is not wearing the bracer:
Say “A hollow voice says ‘Sure you jest!’”;
If the player is wearing the bracer:
Continue the action.

This works for me:

Instead of going east: If the player is in the Seaboard and the player is not wearing the bracer: say "Brecca laughs, 'You're not serious, are you?'"; Otherwise: continue the action.

I just noticed that the indents didn’t come through in the code I suggested. For it to work, the second and fourth lines need to be indented one tab stop, and the third and fifth lines should be indented two tab stops.

 Robert Rothman

Thank you so much, Seeker and Robert! I couldn’t get it, but this works perfectly :smiley:

Or just:

Instead of going east when the player is in the Seaboard and the player is not wearing the bracer:
	 say "Brecca laughs, 'You're not serious, are you?'";

Robert: To preserve indentation, you can use the forum’s code tags.

Thanks, Trumgottist. I gathered that there was a way to do that, but please pardon a very basic question: How do I use the Code tag? Do I just hit the Code button before typing in a slug of code and then hit it again at the end of the block? Or is there more to it?

Robert Rothman

I usually just hit the code button, which pastes the tags “code” and “/code” (surrounded by brackets) into the message. Then I copy and paste the code from the IDE between the tags.

The other method is to copy and paste the code first, then select it using the mouse. Then when you hit the code button, it will automatically place the proper tags around the selected text.

Edited to add: If you can help it (i.e. you’re at a computer with I7 installed), don’t just type the code in – the tabs won’t be preserved. Paste it from the IDE. (This works on windows and presumably mac – I don’t know about the various Linux versions.) In addition to preserving the tabs, it insures you won’t make a typo. If it compiles in your IDE, the pasted version should compile for others. Note also that for pasting code from the forum back into the IDE, you’ll need to follow Matt W’s instructions here:

Of course the third method is just to type (bracket)code(bracket) and (bracket)/code(bracket). :smiley:

It might be helpful to know why this code doesn’t work. “Instead” has two meanings. One is the name of a rulebook (The Instead rules) and the other is a keyword meaning (approximately) “exit the current rulebook with a failure outcome.”

It looks like you were attempting to use the latter form, but that form can’t take a condition in the same way that a “rule preamble” does. I think the compiler interpreted “Instead of going east” as a rule preamble defining an Instead rule that applies when going east. It’s a little weird that this compiled at all, and I’d almost say that was a bug in the compiler. But you can see what happened when you look at the going action in the Actions Index. There are two rules created, not one:

To use “instead” as a keyword within a rule, you could have done this:

Before going east: If the player is in the Seaboard: unless the player is wearing the bracer: instead say "Brecca laughs, 'You're not serious, are you?'";
You can put this form of “instead” before or after a phrase (i.e. an instruction to do something), but not a condition (i.e. an “if statement”).