Scenes can have multiple endings. When two scene endings trigger the same code, one expects to see the same results. I’m not sure why I don’t see the same results. The SCENES debug command shows that the scene is ending correctly, but one ending ends immediately, and the other is delayed.
The scenario is simple. A mad doctor wanders around threatening the player with a lobotomy every time they run in to each other. The encounter is a scene. When the player and the doctor are in the same location, the scene begins. The scene can end abruptly if the player moves to a different room. It can end violently if the player attacks the doctor. And it can end medically if the player waits around until the doctor decides to perform the lobotomy (3 minutes after the scene starts).
The following code illustrates:
Code
The Dispensary is a room.
The Examination Room is a room. It is south of the Dispensary.
The Maintenance Room is a room. It is west of the Dispensary.
The Office is a room. It is north of the Dispensary.
EW Hall is a room. It is east of the Dispensary.
Padded Room is a room. "You are in a small square room." It is north of EW Hall.
A person can be lobotomized or not lobotomized.
Every turn when the player is lobotomized:
meander the player.
The MadDoctor is a man in the Office.
The printed name is "Doctor".
Understand "mad/-- doctor" as the MadDoctor.
Every turn:
unless Lobotomy Practice is happening:
traipse the MadDoctor.
Rule for printing a locale paragraph about the MadDoctor:
now the MadDoctor is mentioned.
After the MadDoctor going when the room gone to is the location of the player:
do nothing.
To lobotomize the player:
move the MadDoctor to the Office;
now the player is in Padded Room;
[move the player to Padded Room, without printing a room description;]
now the player is lobotomized.
To meander the player:
let rando be a random number between 1 and 20;
if Lobotomy Practice has ended:
say "<[minutes part of the time since Lobotomy Practice ended] mins>[line break]";
else:
say "<still practicing>[line break]";
if the time since Lobotomy Practice ended is at least 1 minute:
if rando is at most 5:
say ">west[command clarification break]";
try going west;
otherwise if rando is at most 10:
say ">east[command clarification break]";
try going east;
otherwise if random is at most 15:
say ">north[command clarification break]";
try going north;
otherwise:
say ">south[command clarification break]";
try going south;
follow the scene change machinery rule.
To traipse (npc - a person):
let rando be a random number between 1 and 20;
if npc is not the player:
if rando is at most 5:
try npc going west;
otherwise if rando is at most 10:
try npc going east;
otherwise if rando is at most 15:
try npc going north;
otherwise:
try npc going south.
Lobotomy Practice is a recurring scene.
Lobotomy Practice begins when the MadDoctor is in the location.
Lobotomy Practice ends medically when the time since Lobotomy Practice began is 3 minutes.
Lobotomy Practice ends violently when the current action is attacking the MadDoctor.
Lobotomy Practice ends abruptly when the location is not the holder of the MadDoctor.
When Lobotomy Practice begins:
say "You hear a noise and notice a short, stocky, unshaven man wearing a bloody white surgical gown and holding a large hypodermic is staring at you."
When Lobotomy Practice ends medically:
say "The doctor says, 'I[']m afraid I[']m going to have to give you a frontal lobotomy!' he sticks you with his hypo and you pass out. When you awaken, you feel somewhat indifferent to your surroundings. You feel like wandering...";
lobotomize the player.
When Lobotomy Practice ends violently:
say "The doctor sticks you with his hypo. 'I[']m afraid I[']m going to have to give you a frontal lobotomy!' he says and you pass out. When you awaken, you feel somewhat indifferent to your surroundings. You feel like wandering...";
lobotomize the player.
Every turn during Lobotomy Practice:
if the time since Lobotomy Practice began is at least 1 minute:
let rando be a random number between 1 and 20;
say "The doctor says, ";
if rando is at most 6:
say "'You are not being a good little patient! Now return to your cell, or you will need a lobotomy!'";
otherwise if rando is at most 12:
say "'I grow tired of dealing with you inferiors!'";
otherwise:
say "'What are you doing here? Go where you belong!'".
Plughing is an action applying to nothing.
Understand "plugh" as plughing.
Carry out plughing:
if the player is lobotomized:
now the player is not lobotomized;
say "You get better.";
otherwise:
say "Sorry, that doesn't work right now."
Test violent with "n / attack doctor / look / s / z".
Test medical with "n / z / z / look / s / z".
As intended, if the scene ends violently or medically, a routine is called (lobotomize the player) that moves the doctor to the office, moves the player to the padded room, and makes the player lobotomized. When the player is lobotomized, an every turn rule calls a routine (meander the player) that makes the player move in a random direction. This routine has some debug code to show the number of minutes since the scene ended, and won’t make the player wander until 1 minute after the scene ends.
The issue I’m having is that, if the scene ends violently, everything works fine and meander the player is called after the player is moved. If the scene ends medically, everything works fine, but meander the player isn’t called.