[GS] Difference between ImportFiles and ReplaceUIScript

when using ImportFiles you replace the whole file with yours, while ReplaceUIScript allows you to include the original file you replace at the beginning of your (for example to just overwrite a function of that file)

There are pro and con, I use ReplaceUIScript for minimal changes (or additions without modification of original functions), when I know that in most case an update of the original file will not affect those changes and ImportFiles for bigger modifications of the original functions, when updates of the original files will surely affect my code and then a 3-way merge will be easier.
 
Firaxis uses a ReplaceUIScript fpr Gathering Storm on for example the CityPanel.lua file. This makes the UI "context" for the original CityPanel.lua used by the Vanilla expac to use instead the new lua file (for Gathering Storm called something like CityPanel_Expansion2.lua). One of the very first few lines of code in this new "CityPanel_Expansion2.lua" file is
Code:
include("CityPanel.lua")
Since lua uses a "last definition" method when two or more versions of a function are defined within the same context, Firaxis can then just simply redefine any needed functions in the code of "CityPanel_Expansion2.lua" without needing to disturb anything within the original "CityPanel.lua" file.

If I code the following in lua
Code:
function Kittens()
    print("Kittens have tails")
end

function Kittens()
   print("Meow")
end

Kittens()
I get "Meow" printed into the lua log file and live tuner console.
 
Back
Top Bottom