FrontEnd LUA : include() function didn't work after return to main menu from game

iElden

Chieftain
Joined
Oct 23, 2021
Messages
3
Hello,

I have a huge trouble with my FrontEnd modding.

The include() function seem to work as expected but once a game have started, and then I return to the mainmenu, my mainmenu.lua is correctly loaded but now the include() function seem to have no result.

Exemple:

I have two file, mainmenu.lua and MyImportedData.lua.

let's assume the MyImportedData.lua contains following code :
Code:
print("MyData loaded");
ExposedMembers.myDataIsInit = false;
function InitializeMyData()
    ...
    ExposedMembers.myDataIsInit = true;
end
InitializeMyData();

On my MainMenu (and other many file), I have this code:
Code:
function OnShow()
    ExposedMembers.myDataIsInit = false;
    include("MyImportedData");
    print("result=", tostring(ExposedMembers.myDataIsInit))
    ...

Before I ran any games, I always get "true" as result, and once I got into a game and return to the mainMenu, the result is "false" and the print statement inside MyImportedData.lua is never executed.

On the modInfo, I import the files as the following :
Code:
<FrontEndActions>
  <ImportFiles id="FrontEnd">
        <File>MyImportedData.lua</File>
        <File>ui/mainmenu.lua</File>
        <File>ui/mainmenu.xml</File>
  </ImportFiles>
</FrontEndActions>

I wonder how can I fix it since I really need the use of the "include" statement, putting all into the ExposedMemberswon't work.
The include() function seem to work fine after a return to the main menu for Firaxis file, but not for my included file.

If anyone has any insight to give me on how the "include" function works, I would be very grateful and happy - I've been racking my brains over it for several hours.

Thank you very much.
 
Today I tried to add a .xml for the "MyImportedData", I tried with a <Context> and with an <Include> (to mimick the PopupDialog) but both ran into the same issue, the "include()" function seem not to work for these files after exiting a game.
 
Back
Top Bottom