Every turn when the player is in a room

X is a number that varies. X is 0.

Every turn when the player is in Road:
increment X;
if X is 0:
say “I drive in silence.”;
if X is 4:
say “Fifteen minutes have passed.”;

I have another “every turn” thingy that works, though. How do I get this one to print out the desired text?

I think it’s just that you start X at 0, and then increment it before you check if X is 0. You can get “I drive in silence” to show up by changing the condition to “if X is 1”. “Fifteen minutes have passed” works fine as it is.

Road is a room.

X is a number that varies. X is 0.

Every turn when the player is in Road:
	increment X;
	if X is 1:
		say “I drive in silence.”;
	if X is 4:
		say “Fifteen minutes have passed.”

Nothing under “Every turn when the player is in Road:” works. I added this:

Every turn:
	say "X is [X]"

and the result:

> **go north**

I drive out onto the road.

**Road**

A residential street adjacent to the high school.

X is 0

> **wait**

Time passes.

X is 0

> **wait**

Time passes.

X is 0

> **wait**

Time passes.

X is 0

> **wait**

Time passes.

X is 0

So X is not incrementing at all…

Odd. When I put my code into a completely new project without anything else, it works.

This is a guess, but is your player character in a vehicle? I forget how it works but I think that interferes with checking the player’s location - you’re not directly in Road, you’re in a vehicle that is in Road. Give me a few minutes, and I’ll see if I can find it in the docs.

I’ve had similar experiences with Every Turn: What you might want to check is that your other Every Turn rule doesn’t have an outcome that succeeds or stops the action. Since Every Turn only runs once per turn, if one outcome in the rule succeeds or stops, it will ignore the other rule.

You may wish to combine all your Every Turn processes into one mega-rule and play with the order things happen to make sure everything fires that needs to.

If you have parts that need to fail and succeed, you could split out out. Such as:

Every turn:
     process roads;
     process time;

To process roads:
     If the location is Road:
          [...]

To process time:
     set time = time + 1 [...]
3 Likes

Yes, the player is in a vehicle. I did some more testing and it seems that only whenever Road is involved does the code not work. I tried doing this:

Every turn while the player is in Jeep and the player is in Road:

but it doesn’t work.

Okay, found it. Try “location of the player”:

X is a number that varies. X is 0.

Every turn when the location of the player is Road:
	increment X;
	if X is 1:
		say “I drive in silence.”;
	if X is 4:
		say “Fifteen minutes have passed.”

(If you only want this to work while the player is in the jeep, you might need to add an extra condition.)

“Location of the object” deals with what’s called “indirect” containment - see section 3.25 of the Inform 7 docs. Also see section 6.11, which is the bit that explains that the word “in” only deals with direct containment.

3 Likes

That or just “the location” will always return the room the player is in regardless of containment. The other option is if the player is enclosed by Jeep.

2 Likes

It works! Thanks to both of you. I will keep the bit about Every Turn in mind.

2 Likes