zzragnar0kzz
Chieftain
- Joined
- May 2, 2021
- Messages
- 22
Using AdvancedSetup as an example, the go-to method to make modifications to this script would be to copy the base game's version into your mod, make the necessary changes, and add it via an <ImportFiles> tag in your .modinfo's <FrontEndActions> section. This obviously works, but since only the last imported version of a given file exists, your changes will be overwritten if another mod imports this file after yours, or the other mod's changes will be overwritten if your mod imports this file after it. You could instead start with the other mod's file as a base and make your changes to it, but besides being rather gauche, if you wish to incorporate changes from several mods the final script would quickly bloat to account for everything. You could isolate the changes into one or more separate files and use include directives with or without pattern matching, but that still requires altering and reimporting the base file or another version thereof to include the include directives. The <ReplaceUIScript> tag that can be used to alter Ingame UI elements does not work in the Frontend. So, what do?
Major Frontend Lua contexts appear to be defined in the MainMenu.xml template. By replacing the FileName portion of a given context within this file, we can simulate the behavior of ReplaceUIScript in the Frontend; basically, the new script file contains a line to include the existing file, stores any content to be replaced with new names if necessary, and makes any required modifications. The new file can also contain additional include directives with or without pattern matching to include modifications from other sources, which allows multiple mods to make changes to a given Frontend script without any of them needing to directly alter the original file; as long as they are all modifying different things, all the changes will coexist.
I have edited my own EGHV mod to utilize this method, and have tested with it as the only active mod making changes to AdvancedSetup, where it utilizes the base game's version of that file, as well as alongside YnAMP, where it utilizes that mod's version of that file, and as far as I can tell it is working as expected in both cases. Can anyone with more knowledge and experience chime in as to whether this is a good idea, or if it may cause unforeseen gameplay problems? Much obliged!
Major Frontend Lua contexts appear to be defined in the MainMenu.xml template. By replacing the FileName portion of a given context within this file, we can simulate the behavior of ReplaceUIScript in the Frontend; basically, the new script file contains a line to include the existing file, stores any content to be replaced with new names if necessary, and makes any required modifications. The new file can also contain additional include directives with or without pattern matching to include modifications from other sources, which allows multiple mods to make changes to a given Frontend script without any of them needing to directly alter the original file; as long as they are all modifying different things, all the changes will coexist.
I have edited my own EGHV mod to utilize this method, and have tested with it as the only active mod making changes to AdvancedSetup, where it utilizes the base game's version of that file, as well as alongside YnAMP, where it utilizes that mod's version of that file, and as far as I can tell it is working as expected in both cases. Can anyone with more knowledge and experience chime in as to whether this is a good idea, or if it may cause unforeseen gameplay problems? Much obliged!