Very confusing behavior difference between 'to say' and 'instead of'

I swear I’ve used this same kind of code dozens of times, but I came up with the wildest bug in my code today.

I have an object I want to have different descriptions the first and second time you look at it. When I use ‘to say’, that doesn’t happen. When I use ‘instead of’, it does. Here’s the code:

Playroom is a room.

The ball is in playroom.

The description of the ball is "[balltext]!"

Ballseen is a truth state that varies. Ballseen is false.

To say balltext:
	if ballseen is true:
		say "I already looked at the ball";
	otherwise:
		say "I'm looking at the ball for the first time!";
		now ballseen is true;
		
The cube is in playroom.

The description of the cube is "The player will never see this."

Cubeseen is a truth state that varies. Cubeseen is false.

Instead of examining the cube:
	if cubeseen is true:
		say "I already looked at the cube.";
	otherwise:
		say "I'm looking at the cube for the first time!";
		now cubeseen is true;
		
Test me with "x ball/x ball/x cube/x cube"

If you test it out, the ball and cube have very different behavior. The ball immediately skips to the second description, while the cube does not.

Why does the ball skip over? Even more confusing is the following:

"Sandbox" by Brian Rushton

Playroom is a room.

The ball is in playroom.

The description of the ball is "[balltext]!"

Ballseen is a truth state that varies. Ballseen is false.

Jumpflag is a truth state that varies. Jumpflag is false.

To say balltext:
	if ballseen is true:
		say "I already looked at the ball";
	otherwise:
		say "I'm looking at the ball for the first time![jumptime]";
		now ballseen is true;
		
To say jumptime:
	now jumpflag is true;
	
Every turn when jumpflag is true:
	try jumping;
	now jumpflag is false;

The cube is in playroom.

The description of the cube is "The player will never see this."

Cubeseen is a truth state that varies. Cubeseen is false.

Instead of examining the cube:
	if cubeseen is true:
		say "I already looked at the cube.";
	otherwise:
		say "I'm looking at the cube for the first time!";
		now cubeseen is true;

When looking at the ball for the first time, it prints the text from the second option, but executes the command about jumping in the first option! Why???

1 Like

See the discussion of “expanding text for comparison purposes”, e.g. here: Expanding text for comparison purposes... but not?

1 Like

Just wanted to add in that this behaviour doesn’t happen with description-changing code you use for a say phrase that creates a room description, as spelled out more laboriously in this topic:

-Wade

1 Like

wasn’t more simple using adaptive prose (I7/10’s forte…) ?

there’s a nifty “[first time]…[only]” :slight_smile:

Best regards from Italy,
dott. Piergiorgio.

1 Like