Me and my friends like to play civ 5 "by email", and thus there is a lot of loading and saving of hotseat games going on. In an effort to reduce the amount of clicking, I have made a modified version of the load menu (LoadMenu.lua and LoadMenu.xml) which opens when civ opens and loads the file with just 1 click.
I would now like to modify the save menu (SaveMenu.lua and SaveMenu.xml) so that it, upon clicking the "Save game" button in the player changer menu, automatically saves the game, using the same name of the file that was loaded. Passing any arbitrary string to the save function was easy, but I'm having trouble getting the name of the file from the load menu. I've tried to read about UI mods, but what I find is mostly related to in game UI.
What I've tried so far:
- Calling Pregame.GetLoadFileName(). I thought this was supposed to persist even in game? However, I found some indications that this is only applicable for multiplayer games (and hotseat games are not technically considered multiplayer), if I understand things correctly? It is empty when I am in game, and even if i set the name manually when loading the file, it is still empty when trying to save.
- Storing the string in mapmoddata. I encountered an error trying to create the tables, and checking with Fire Tuner, I don't think mapmoddata is created until the map has been created, which is obviously too late in my case.
- Creating a global variable to which both LoadMenu.lua and SaveMenu.lua can write/read. So far all my attempts have simply resulted in there being a separate variable for both files. In other words, adding this to LoadMenu.lua:
and then trying to read g_FileName from SaveMenu.lua only shows "Empty". I've tried several variants, including using LuaEvents to edit or get the variable but still the same result. No difference if I place the variable in LoadMenu or SaveMenu, or in any other lua file for that matter.
How can I make the variable truly global? Or is there some other way I can store the string? Or perhaps there is another way to get the file name when I am already in game?
Any and all help is greatly appreciated!
I would now like to modify the save menu (SaveMenu.lua and SaveMenu.xml) so that it, upon clicking the "Save game" button in the player changer menu, automatically saves the game, using the same name of the file that was loaded. Passing any arbitrary string to the save function was easy, but I'm having trouble getting the name of the file from the load menu. I've tried to read about UI mods, but what I find is mostly related to in game UI.
What I've tried so far:
- Calling Pregame.GetLoadFileName(). I thought this was supposed to persist even in game? However, I found some indications that this is only applicable for multiplayer games (and hotseat games are not technically considered multiplayer), if I understand things correctly? It is empty when I am in game, and even if i set the name manually when loading the file, it is still empty when trying to save.
- Storing the string in mapmoddata. I encountered an error trying to create the tables, and checking with Fire Tuner, I don't think mapmoddata is created until the map has been created, which is obviously too late in my case.
- Creating a global variable to which both LoadMenu.lua and SaveMenu.lua can write/read. So far all my attempts have simply resulted in there being a separate variable for both files. In other words, adding this to LoadMenu.lua:
Code:
g_FileName = "Empty";
function OnStartButton()
(...other stuff...)
g_FileName = "MySaveFile";
(...other stuff...)
end
How can I make the variable truly global? Or is there some other way I can store the string? Or perhaps there is another way to get the file name when I am already in game?
Any and all help is greatly appreciated!