Prevent "When a scene begins:" from being triggered by "The Entire Game" scene

I would like to prevent When a scene begins: from being triggered by The Entire Game scene as in:

“Test Game” by mim

Test Scene is a scene. Test Scene begins when play begins.

When a scene begins:
say “Kek!”.

The Test Room is a room.

Kek!

Kek!

Test Game
An Interactive Fiction by mim
Release 1 / Serial number 200305 / Inform 7 build 6M62 (I6/v6.33 lib 6/12N) SD

Test Room

The blur spoiler marks the “Kek!” triggered by The Entire Game scene.

I lazily tried the following (compiler errors):

When a scene begins other than The Entire Game:

When a scene (other than The Entire Game) begins :

When a scene (that is not the The Entire Game) begins:

1 Like

Here’s one way to do that: We could give the rule a name and tell Inform that it doesn’t do anything on the first turn, which is when play begins. This construction could come in handy if we want to define additional exceptions later.

Of course, this will also suppress the “Kek” from our Test Scene on the first turn. So if we do want the one “Kek” to show up, we can insert it manually one time when play begins.

Test Scene is a scene.
Test Scene begins when play begins.

When a scene begins (this is the scene-beginning rule):
	say “Kek!”.

The scene-beginning rule does nothing when the turn count is one.

The Test Room is a room.

When play begins:
	say "Kek (manually inserted)!".

Alternatively, if you don’t need the named rule for other exceptions, you could just say:

When a scene begins:
	if the turn count is not one:
		say “Kek!”.

(Edited to add: of course, you can also express additional exceptions within that if structure.)

4 Likes

So the problem you’re having is that you’re getting a duplicate message (or code is being run twice) at the start of your game, correct?

Try

When the game begins:
(tab) say “The message I only want said once.”;

Complicated stuff is a scene. Complicated stuff begins when play begins.

When complicated stuff is happening:
(tab) restrictions on play go here;


Sorry I can’t test this, I’m on a friend’s mac, and don’t have the permissions to install Inform on it.

1 Like

This works:

When a scene (called S) begins when S is not Entire Game:
	say "Scene [S]."

If you wind up using scenes for several purposes, it may wind up easier to define a property on scenes.

A scene can be kek-worthy.

When a scene (called S) begins when S is kek-worthy:
	say "Scene [S]."
3 Likes

Zarf’s method works great, but to show another alternative:

Definition: a scene is announceable if it is not the Entire Game.
When an announceable scene begins…
3 Likes

I am only an intfiction copy-paster, so I am just blown away by your insigthful answers. Thank you all!

1 Like