"...in X turns" timer issue

What is wrong with this code? It compiles, but Your_Ride begins on the next turn after ridetime is true, instead of three turns later.

I’ve scoured the forum and found several possible solutions to this issue, but none work in my case. It feels like this should be simple…

Your_Ride is a scene. Your_Ride begins when ridetime is true for the third turn.
When Your_Ride begins:
	say "YourRide".

Thanks in advance!

No doubt the experts will chime in but I remember coming across delayed actions like this, and I had to tweak the count.

If you change ‘third’ to ‘fifth’, would that achieve the effect you are looking for?
(I will leave it to the experts to explain the exact time of things, it always messes me up :frowning: )

1 Like

YES! It worked, you are a genius my friend :slight_smile:

A genius? :smiley: Wait till the REAL geniuses show up…

9.15. How many turns? (ganelson.github.io) is the relevant bit of documentation but scenes work slightly differently when timing is involved is my guess.

10.2. Creating a scene (ganelson.github.io) also mentions an example:

Train Stop is a scene.
Train Stop begins when the player is in the Station for the third turn.

But that suffers the same problem as yours, and I have to increase the turn count to make it start at the proper time.

1 Like

Smells like that there’s the fencepost error (aka off-by-one error) somewhere…

Best regards from Italy,
dott. Piergiorgio.

1 Like

The scene changing machinery runs twice each turn:

once before the turn count is incremented, time advanced and chronological records are updated (the latter being truth states that monitor such conditions as ‘for the third turn’ etc.) and once after

So if an action makes ridetime true

  • on that turn
    – the first time the scene changing rules run, ridetime is true for one turn
    – then the turn count is incremented
    – then the second time the scene changing rules run, ridetime is true for two turns

  • on the following turn
    – the first time the scene changing rules run, ridetime is true for two turns
    – then the turn count is incremented
    – then the second time the scene changing rules run, ridetime is true for three turns

EDIT: so effectively, a new turn begins immediately after the advance time rule has run, which is why ‘for three turns’ becomes true for scene changes before the command prompt appears for the second time after the action that made the condition true.

The following demonstrates this happening:

Carry out jumping: now ridetime is true.

ridetime is initially false.

First scene changing rule:
	say "turn number [turn count], ridetime [ridetime].";
	say "ridetime is [if ridetime is true for the first turn]true for the first turn[end if][if ridetime is true for the second turn]true for the second turn[end if][if ridetime is true for the third turn]true for the third turn[end if][if ridetime is false or ridetime is true for more than three turns]being monitored[end if]."

>z
Time passes.

turn number 1, ridetime false.
ridetime is being monitored.

turn number 2, ridetime false.
ridetime is being monitored.

>z
Time passes.

turn number 2, ridetime false.
ridetime is being monitored.

turn number 3, ridetime false.
ridetime is being monitored.

>jump
You jump on the spot.

turn number 3, ridetime true.
ridetime is true for the first turn.

turn number 4, ridetime true.
ridetime is true for the second turn.

>z
Time passes.

turn number 4, ridetime true.
ridetime is true for the second turn.

turn number 5, ridetime true.
ridetime is true for the third turn.

YourRide
>z
Time passes.

turn number 5, ridetime true.
ridetime is true for the third turn.

turn number 6, ridetime true.
ridetime is being monitored.

The practical result is:

  • if you want your scene to start before every turn etc. run on the turn an action makes the condition true, use ‘for one turn’
  • if you want your scene to start after every turn etc. run after an action makes the condition true, use ‘for two turns’
  • if you want your scene to start after every turn etc. run on the turn following after an action makes the condition true, use ‘for three turns’
  • etc.
5 Likes

That explains it! I appreciate the information.