Check before Going to another Room

I just know my syntax is wrong here but I can’t figure it out.

Before going to the Afterlife: check if the metal door is locked; if the metal door is locked; the action fails.

So basically, before the player “dies” and enters the room called Afterlife I want it to check if the metal door is locked.
If the metal door isn’t locked I want to player to not “die” and instead get a print out saying “You fail and are saved.”
If the metal door is locked then I want the action to continue.


I think the issue is that you’re moving the player to the Afterlife manually rather than via the going action, so the rule never triggers.

I’d try performing this test in the same place that you “kill” the player. If that’s multiple places, you can break it out into a named phrase (“to kill the player: …”) and call it from all of those places.

A door called the metal door is east of the Front Room and west of the Back Room.
The metal door is lockable and locked.
The matching key of the metal door is The Key of Death. The player carries The Key of Death.

Rule for writing a paragraph about the metal door:
	say "The metal door is [if the metal door is unlocked]un[end if]locked.";

The Afterlife is a room.

The player carries an edible thing called a poisoned apple.

After eating the poisoned apple:
	say "You eat the poisoned apple...[paragraph break]";
	kill the player.
To kill the player:
	if the metal door is unlocked:
		say "You fail and are saved.";
	say "[bold type]*** You have died ****[roman type][line break]";
	now all things carried by the player are nowhere;
	now the player is in the Afterlife.
Does the player mean unlocking the metal door with the Key of Death:
	it is very likely.
Does the player mean locking the metal door with the Key of Death:
	it is very likely.

Besides what Vince said about moving automatically versus going, a couple of things:

You don’t need “check if the metal door is locked.” Just write “if the metal door is locked:” and that carries out a test for whether the metal door is locked.

Also, “the action fails” mixes two different syntaxes. Usually you want “stop the action.” “Rule fails” can also be used and generally means the same thing (there’s a ridiculously subtle distinction that you won’t encounter), but it’s probably easier to remember what “stop the action” does: It stops whatever action is going on.

So, this will compile:

Before going to the Afterlife: if the metal door is locked: stop the action.

or more elegantly:

[code]Before going to the Afterlife when the metal door is locked:
stop the action.[/stop]

But, in line with what Vince said, this is a rule for the action of going; it’ll only trigger when the player types “GO WEST” and the Afterlife is west of where they are (or something like that). This rule will stop that action. But if you have another rule that moves the player to the Afterlife, this rule won’t stop it, because the player isn’t carrying out a Going action of going to the afterlife.

Also, this rule wouldn’t print a message; it would just stop the action without saying anything, and any other rules pertaining to the action wouldn’t run. So even if you have another rule that’s meant to print a message it wouldn’t run. If you have a rule that cuts off an action you should print any messages pertaining to it within that rule.