Moving into a room and actions taking place based on clothing

I wrote this little piece to indicate before entering the room c heck to see if the player is wearing a jumpsuit. If he/she is then the worker is to giver a key to him otherwise nothing happens…it does not work for me. What am I missing?

Before entering Boat Dock:
if player is wearing Maintenance Jumpsuit:
move the Maintenance Key to player;
say “The Worker looks at you and says ‘Hey new guy, go fix the vending machine over by the gift shop.’ He tosses you a key.”;

Any help would be great!
Thanks

How is the player getting to the Boat Dock? If it’s just an ordinary location that you reach by typing in a compass direction, the verb for that is Going, not Entering (if you type ACTIONS in the IDE before trying to go to the Boat Dock, you can confirm exactly what the game is trying to do).

You’d probably also need some additional code to make sure this doesn’t happen every time the player enters the Boat Dock and/or when the player already has the key.

Thanks got it fixed and with an additional line it only does it if the worker has the key and the player is wearing the jumpsuit.

I did find another interesting anomaly… When the going to is done…the Room name and desc do not appear? If I put a continue the action after the say it shows up but After the worker talks…putting it anywhere else doesn’t give desired effect. What am I missing?

After going to Boat Dock:
if player is wearing Maintenance Jumpsuit and Maintenance Worker is carrying the Maintenance Key:
move the Maintenance Key to player;
say “The Worker looks at you and says ‘Hey new guy, go fix the vending machine over by the gift shop.’ He tosses you a key.”;
otherwise:
continue the action.

After rules replace the normal reporting behavior so that’s working the way it should – if you want to display the usual room info, you can also add a “try looking” line to your code in the appropriate place.

(Also, this may or may not be what you’re intending to do, but since the “continue the action” line comes after the Otherwise condition in the excerpt above, it’s only firing in cases where the If statement doesn’t apply, i.e. when the player isn’t getting tossed the key).

the try looking got it.
thanks

After going rules occur after the movement but before the new location description is shown (and by default will prevent the description being shown, as you’ve discovered).

This is fine if something is happening as a result of the movement itself, but usually when I think I want to write an after going rule it’s because I want something to happen shortly after the player has arrived in the new location, and I think it’s better to show that by printing the location description first and then the consequences afterwards. The simplest method I’ve found to do this is to use an every turn rule instead:

Every turn when the location is Boat Dock:
	if the player is wearing Maintenance Jumpsuit and Maintenance Worker is carrying the Maintenance Key:
		now the player carries the Maintenance Key;
		say "The Worker looks at you and says 'Hey new guy, go fix the vending machine over by the gift shop.'[paragraph break]He tosses you a key."

This also forces you to remember to write the conditions such that it will only happen once (or however often you actually want it to happen), which can be easy to forget in an after rule.

(You can actually combine all the conditions into the header of the rule, which is actually slightly better if you use rules tracing, but otherwise doesn’t make any real difference – although it does have an effect on the order that rules execute.)

Incidentally, when you want to post code snippets you should surround the code block with three backticks (```); this preserves the spacing and prevents quotes from being changed, keeping the proper formatting as above.

I’ve always found that the “actions” and “rules” debugging tools are very useful when I’m trying to work out what’s going on when my code misbehaves. Simply play to the point in your story just before it all goes pear-shaped and then type:

> actions on

at the prompt. The game will now print up information about which action(s) it’s invoking, which is very handy if one action has been redirected into another without you realizing. Similarly the command:

> rules on

will cause Inform to announce each rule that it tries, in order (very handy when trying to write NPC interactions where the rules involved are a bit labyrinthine.) Typing “actions off” and “rules off” returns you to normal play.

Because these are defined as debugging tools, you don’t need to worry about how they will affect your game or players using them to cheat. When you use the “compile for release” instruction, they will automatically be omitted from the game.