Newbie Question about If Otherwise

I am trying to make the Player do an extra step to take an object called cone.
Ive tried using otherwise but cannot get the syntax correct.
The current code I have that almost works is below but I cant get the cone back to the player,. It remains in the room. Any help would be helpful.

after taking the cone:
		if Attendant is in Parking Lot, say "The attendant scowls at  you and says 'Drop it'.";
		now cone is in Parking Lot.
after taking the cone:
		 say "Taken";
		now the player is carrying cone.	`

The specific syntax issue you’re running into is that your If statement is only applying to the Say statement, not the “now cone is in parking lot” bit (that is, if the attendant is in the lot, you’ll see the text about scowling, but regardless of where the attendant is, the cone’s going back to the parking lot). This should work:

If the Attendant is in the Parking Lot:
	Say "The attendant scowls...";
	Now the cone is in the parking lot.

With that said, I think you’d be better off doing this as single Before or Instead rule, since what you’re basically doing is trying to prevent the action of taking the cone under a specific circumstance, rather than two different after rules whose order of operations isn’t necessarily clear and which moves the cone around unnecessarily.

Instead of taking the cone while the Attendant is in the Parking Lot, say "The attendant scowls...".
1 Like

Maybe there’s something more complex going on than I can see, but this looks more complicated than is necessary. Here’s how I would rewrite the whole section:

instead of taking the cone when the Attendant is visible, say "The attendant scowls at  you and says 'Don[']t even think about it'."

You could also do this with a Before ... instead rule, which would prevent the action from even starting:

Before taking the cone when the Attendant is visible, say "The attendant scowls at  you and says 'Don[']t even think about it'." instead.

This prevents the action from occurring in the first place, rather than making the player abashed about it afterwards, but (arguably) has the same in-game effect: the player can’t take the cone while the Attendant is visible. (Note that this rule, as written, isn’t restricted to the parking lot: the player will be unable to take the cone from anywhere if s/he can see the Attendant, which may or may not be what you want.)

Another problem with the first paragraph is that the line now cone is in parking lot is executed whether or not the condition if Attendant is in Parking Lot is true or not; this is because it’s not indented any further than the line if Attendant is in Parking Lot. If you indent now cone is in Parking Lot one more tab level, it will only run if Attendant is in Parking Lot. This would probably, I’m guessing, also mean that you don’t need that second after taking the cone rule at all, because you won’t be trying to work around having dropped the cone unnecessarily.

Does that help?


Actually that’s not sufficient by itself, because the first line is using the if condition, action style, which only supports single actions. In order to set up multiple actions then the first action has to be moved to the next line and indented, and the comma has to be replaced with a colon. Otherwise Inform will complain about mixing coding styles.

But using an Instead rule as you’ve suggested is better anyway. Better to prevent the action from being carried out in the first place rather than trying to messily reverse it and then re-reverse it.


Good call! I should have said I am on mobile and had not checked the code in the IDE. Thank you, Gavin.

Verified good answer, thank you. On to the next query. Multiple excits…

I have three rooms A,B,C
C is north of A
C is north of B

What is the syntax I should use,. I’ve tried what my limited knowledge can do.

I recommend starting a new thread for your new question. That will help any others with similar questions in the future find it.

1 Like

Good suggestion. Doing it now.

1 Like