Compound conditions for the first time

I was trying to get a for the first time clause to work with a compound condition, like this:

Lab is a room.
the ball is in the lab.

Instead of Jumping:
	now turn count is 0;
	say "Turn count reset.";	
Every turn:
	if turn count is 0 and the player carries the ball for the first time:
		say "foo";
test me with "take ball/jump/jump".

but no luck. It fires every time I jump. This seems to contradict what WI implies (but doesn’t demonstrate), which is that any condition will work:

if (…condition…) two times…

I trying using parens around the compound action and get a compile error, which also seems wrong.

Is there any way to make this work?

ETA: On second thought, I can see why this wouldn’t work. If the game is tracking when the condition becomes true rather than how many times it passes this gate in the code, it can only track conditions of objects, I imagine.

1 Like

The compiler can track any boolean condition. It checks them once per turn.

Okay, good to know. I’m confused as to why the above example doesn’t work then.

The compiler just isn’t set up to consider paretheses around conditions.

You can break out the test into a function or other testable adjective. This works:

To decide whether zero-carried-ball:
	if the turn count is 0 and the player carries the ball:

Every turn when zero-carried-ball:
	if zero-carried-ball for the first time:
		say "foo";

Thanks. I’m still forgetful of the idioms of Inform.


Every turn:
	if the player carries the ball and turn count is 0 for the first time:
		say "foo";

also seem to work the same as Zarf’s code, am I correct to assume that

  • a. for the first time binds stronger than logical and, and
  • b. logical and does short circuit evaluation in Inform 7?

It’s not the same. Your example compiles to

    if ((((player == CarrierOf(I127_ball)))) && ((TestSinglePastState(0, 1, false, 1) == 1 )))
    ! the past-state test is run on (turns == 0)

Mine compiles to

    if ((TestSinglePastState(0, 0, false, 1) == 1 ))
    ! the past-state test is run on (zero-carried-ball)

Those are both true.

1 Like