Thalassicus
Bytes and Nibblers
Mods with global lua variables break when a save is loaded from within an existing game. For example, consider this code:
(This code is in a file imported to the VFS, and included in other core UI files. I'm uncertain if that is an important factor.)
When a game starts this prints in the tuner:
Now perform these steps:
Everything still works. Now without exiting to the main menu, load the save while still in a game. Only this prints to the tuner:
MapModData.VEM is already set in this new game, even though it was actually set in the previous game. This is inconsistent with loading games from the main menu. This problem has existed since at least March, but it took me half a year to identify precisely what was going wrong.
PHP:
print("Check MapModData.VEM")
if not MapModData.VEM then
print("Loading MapModData.VEM")
MapModData.VEM = {}
end
When a game starts this prints in the tuner:
Code:
CiVUP - Events: Check MapModData.VEM
CiVUP - Events: Loading MapModData.VEM
- Save the game.
- Exit to the main menu.
- Load the save.
Code:
CiVUP - Events: Check MapModData.VEM
CiVUP - Events: Loading MapModData.VEM
Code:
CiVUP - Events: Check MapModData.VEM