Setting the scene begin condition as a custom... (SOLVED)

[code]The Quidditch Pitch is a room. The Match is a scene. The Match begins when the start is called. The Match ends when the player is not in the Quidditch Pitch. Madam Hooch is a woman in the Quidditch Pitch. Blowing is an action with past participle blown applying to one thing. The whistle is in the Quidditch Pitch. The whistle can be blown. Understand “blow [something]” as blowing.

Carry out blowing the whistle:
say “The whistle screams, and the players kick off!”.

To decide whether the start is called:
if the whistle was blown:
if the player is in the Quidditch Pitch, decide yes;
decide no.

Every turn:
if The Match is happening, say “Match began properly.”.[/code]

Currently this doesn’t work, as in, the scene does not begin. The every turn piece of code is just there to test whether or not the match began properly.

Right now I’m just trying to get The Match to start when the player blows the whistle. Currently that is not working. Eventually I want it to start when Madam Hooch blows the whistle, so I also need help on how to get a non-player actor to perform an action like “blow the whistle.”

Thanks!

This part of your code isn’t doing what you want:

 Blowing is an action with past participle blown applying to one thing. The whistle is in the Quidditch Pitch. The whistle can be blown.

“The whistle can be blown” doesn’t actually tie in with the past participle of blowing. That line creates an on/off property for the whistle, “blown,” which you have to change manually. This is one way:

Carry out blowing the whistle: now the whistle is blown; say "The whistle screams, and the players kick off!".

Though this has the problem that the scene starts one turn too late.

You can also make use of the past participle by omitting “The whistle can be blown” and changing the syntax in your “to decide” phrase:

[code]
The Quidditch Pitch is a room. The Match is a scene. The Match begins when the start is called. The Match ends when the player is not in the Quidditch Pitch. Madam Hooch is a woman in the Quidditch Pitch. Blowing is an action with past participle blown applying to one thing. The whistle is in the Quidditch Pitch. Understand “blow [something]” as blowing.

Carry out blowing the whistle:
say “The whistle screams, and the players kick off!”.

To decide whether the start is called:
if we have blown the whistle:
if the player is in the Quidditch Pitch, decide yes;
decide no.

Every turn:
if The Match is happening, say “Match began properly.”[/code]

The “if we have blown the whistle” syntax is documented in sections 9.13-9.16 of Writing with Inform. (Actually this specific syntax only seems to come up at the very end!) Here the match starts on time. (I’m not sure why, I really don’t understand much about scenes.)

Now, there’s another issue, which is that you probably don’t want the player to blow the whistle to start the match. I’ve made some more changes to insure that Madam Hooch blows the whistle (after you wait), and that you can’t grab the whistle from her to blow it, and for that matter that you have to have it to blow it – though as I have it, if you were somehow able to convince her to give the whistle up, you could start the match by blowing it yourself. See if you can tell what part of the code is doing this. (And some of this is done not by my code but by stuff that’s built in to the Standard Rules; for instance, the bit that won’t let you take the whistle if Madam Hooch has it.)

[spoiler][code]
The Quidditch Pitch is a room. The Match is a scene. The Match begins when the start is called. The Match ends when the player is not in the Quidditch Pitch. Madam Hooch is a woman in the Quidditch Pitch. Blowing is an action with past participle blown applying to one carried thing. Madam Hooch carries a whistle. Understand “blow [something]” as blowing.

Report an actor blowing the whistle:
say “The whistle screams, and the players kick off!”.

To decide whether the start is called:
if we have blown the whistle:
if the player is in the Quidditch Pitch, decide yes;
decide no.

Every turn:
if The Match is happening, say “Match began properly.”.

Instead of waiting in the Quidditch Pitch when the Match is not happening:
try Madam Hooch blowing the whistle.[/code][/spoiler]

NB: In this code, if you were somehow able to leave the Pitch and come back, waiting again would cause Hooch to blow the whistle again, even though the Match doesn’t start up again. If you want to incorporate that, you’d want to fix it somehow.

Thanks, that is incredibly helpful!

The scene starts a turn late in the first version because the test is “if the whistle was blown”. The use of “was” here means that the state of affairs at the beginning of the turn is checked, rather than the current state of affairs. Therefore this is not true until the next turn. To get it to start on time, use “if the whistle is blown”. Or even better, both: “if the whistle was not blown and the whistle is blown”; this will only be true on the exact turn the whistle changes from “not blown” to “blown”. But the second version is probably better in any case.

This solves a scene-triggering question I’ve been mystified by for some time. Thankyew :slight_smile:

I reported it as a bug that the documentation was inaccurate about what “If we have blown the whistle” does, and the Inform folk converted it to a bug that “If we have blown the whistle” doesn’t do what the documentation says. So it’s possible (likely, even) that in the next release or two of Inform this will stop working, since “if we have blown the whistle” will be changed so it works only when the player blows the whistle, not Madam Hooch.

EDIT: For the record several years later: Graham said that Inform’s behavior was correct and the documentation was wrong; so this code still works when Madam Hooch blows the whistle.