Overwrite single function

Seti_PL

Chieftain
Joined
Aug 18, 2015
Messages
40
I needed to change logic of AreAllCityStateSlotsUsed from files AdvancedSetup.lua and HostGame.lua. I achieved this by making copy of these files and including changed versions in my mod. Is there any way to overwrite only single function from these game files, instead replacing entire files?

My modinfo responsible for replacing files:

Code:
<?xml version="1.0" encoding="utf-8"?>
<Mod id="cd709a8e-6aaa-4545-a5da-1d4972109032" version="1">
    ...
    <FrontEndActions>
        <ImportFiles id="Update">
            <File>Override/AdvancedSetup.lua</File>
            <File>Override/HostGame.lua</File>
        </ImportFiles>
    </FrontEndActions>
    <Files>
        <File>Override/AdvancedSetup.lua</File>       
        <File>Override/HostGame.lua</File>       
    </Files>
</Mod>
 
let me know if you found one.
 
I have not tried this with CIV yet but I am sure I have done this elsewhere. Perhaps I will try when I get a chance.

If the function is part of class then it is easy. If you want to replace the class function Class1.Func2()
function MyFunction()
.....
end function
Class1.Func2 = MyFunction

If the function is local to the file it is declared in then I don't think there is a chance.

If it is global (you can call it from your own code) then I believe you can do something similar.

Now of course this is in LUA so the code you are overwriting may already have run at the start of the game before you can overwrite it.
 
Most of the functions are local, so it would be great if it is possible to overwrite them, but unlikely.
 
that one is local, defined in both file, and there is no way AFAIK to append another file to <FrontEnd> as for the <InGame> UI files.

and even when you want to implement such function, there was a bug which unloaded the files from the game's system when starting a game and going back to the menu. Not sure if it has been corrected since.
 
Back
Top Bottom