Status bar text: Making it sometimes centered (when waiting for any key) and sometimes not centered

I was experimenting with trying to display a centered message in the status bar while waiting for the player to press a key. But at other times, I’d like to print text on the left and right sides of the status bar.

With this code, the centered status bar message shows correctly while waiting for a keypress. But the rest of the time, the status bar is blank, and I don’t want it to be.

Any suggestions?

Include Basic Screen Effects by Emily Short.

To update/redraw the/-- status line: (- DrawStatusLine(); -).

Prompting-a-keypress is a truth state that varies. Prompting-a-keypress is false.

To prompt the player to press a key:
	now prompting-a-keypress is true;
	update the status line;
	wait for any key;
	now prompting-a-keypress is false.
	
Rule for constructing the status line:
	If prompting-a-keypress is true:
		Center "PLEASE PRESS ANY KEY" at row 1;
	otherwise:
		now the left hand status line is "[player's surroundings]";
		now the right hand status line is "Placeholder";
	rule succeeds.

Lab is a room.

Instead of jumping:
	Say "Something dramatic happens.";
	prompt the player to press a key.

The trick is that the “left hand status line” and “right hand status line” variables are only consulted by the default rule for constructing the status line. Since your new rule for constructing the status line overrides that, the variables are never checked.

Instead, I’d recommend making your new rule only apply when prompting-a-keypress is true. Then the default rule will take over in any other circumstances. (You can set those variables outside the activity, since your new rule doesn’t need them.)

1 Like

Thanks so much!

For future reference, this is what the working version looks like:

Include Basic Screen Effects by Emily Short.

To update/redraw the/-- status line: (- DrawStatusLine(); -).

Prompting-a-keypress is a truth state that varies. Prompting-a-keypress is false.

To prompt the player to press a key:
	now prompting-a-keypress is true;
	update the status line;
	wait for any key;
	now prompting-a-keypress is false.
	
Rule for constructing the status line when prompting-a-keypress is true:
	Center "PLEASE PRESS ANY KEY" at row 1;
	rule succeeds.
	
When play begins:
	[The left hand part is the same as the default status line, so it can be left out:
	now the left hand status line is "[player's surroundings]"; ]
	now the right hand status line is "Placeholder".

Lab is a room.

Instead of jumping:
	Say "Something dramatic happens.";
	prompt the player to press a key.