I was wondering what happens exactly when a Glulx real time event fires during a turn (after the player has entered a command but before the next prompt is displayed).
Let’s say that the NPCs perform actions on their own every N seconds. (And let’s not discuss whether it’s a good idea. I’m only experimenting and it’s just an example.) All the messages are displayed in a side window so that nothing interferes with the prompt.
What happens when an NPC does something during a player’s action? Do the current action pauses, to let the NPC do their thing, then resumes?
If that’s the case, can this scenario happen:
- The player tries to take the apple. The check rules are considered but they all pass without stopping the action.
- Just after that, the NPC also tries to take the apple. The player’s action pauses, the NPC takes the apple, a message is displayed saying so, and the NPC now carries it.
- But then the player’s action resumes and the carry out taking rules are applied. The player now carries the apple, effectively stealing it to the NPC.
This case is quite simplistic, but I think bigger bugs can arise in more complicated situations.
Maybe it’s better, to avoid any problem, to set a flag after reading a command (and unset it before reading a command) and forbid any real time event when the flag is set?