Aleph-One-Marathon / alephone

Aleph One is the open source continuation of Bungie’s Marathon 2 game engine.
https://alephone.lhowon.org/
GNU General Public License v3.0
644 stars 100 forks source link

terminal_exit Lua trigger is called at the start of a new game #498

Closed jonirons closed 3 months ago

jonirons commented 3 months ago

If I have a Solo Lua script enabled that sets the terminal_exit trigger, and start a new game, the trigger is called regardless of the presence of terminals in the level or the state of the player looking at a terminal. It also occurs before init is triggered.

This occurs only the first time I start a new game after starting the program. I have confirmed that I do not encounter this behavior when restoring from a saved game, even if it's the first thing I do after starting the program.

I have confirmed this on Aleph One 1.7.1 and 1.8.1

Here is a sample Lua script:

Triggers = {}

function Triggers.init(restore)
    print("Triggers.init", restore)
end

function Triggers.terminal_exit(terminal, player)
    print("Triggers.terminal_exit", terminal, player)
end

Here is the output to stdout with # commentary.

First run:

$ alephone ~/games/Mararthon\ Infinity/
Aleph One Linux 2024-05-13 1.8.1
[...]
Triggers.terminal_exit  nil player 0
Triggers.init   false
Triggers.init   false

Note that the terminal object was nil.

You can see from Triggers.init that I started two new games. In each case, I saved the game using Game.save(). The first save was intended to capture any relevant state that might cause or prevent the behavior upon load. The second was to see if an untainted save would start exhibiting the behavior. Neither had this issue. The # comments were actually typed into the CLI, to help me keep track of which was which.

$ alephone ~/games/Mararthon\ Infinity/ # restore from first save
Aleph One Linux 2024-05-13 1.8.1
[...]
Triggers.init   true

$ alephone ~/games/Mararthon\ Infinity/ # restore from second save
Aleph One Linux 2024-05-13 1.8.1
[...]
Triggers.init   true