MF99K Posted February 1, 2016 Share Posted February 1, 2016 I was wondering a bit how overrides and code priorities work in mods. I understand how to adjust tuning variables with configuration options, but how would I replace prefab files(or do mod prefabs get priority), and is it possible to configure existing components? Link to comment https://forums.kleientertainment.com/forums/topic/63588-mod-overrides/ Share on other sites More sharing options...
Mobbstar Posted February 1, 2016 Share Posted February 1, 2016 (edited) You can manipulate most Lua scripts using so-called Post-Init functions. You probably know "AddPrefabPostInit()" already. The rest can be seen in data/modutil.lua or in the API example mod. Mods can also contain a copy of a game file (must be in the same directory, e.g. "../scripts/prefabs"), which will be loaded instead of the original. If two mods do this, the game crashes, I think. So if you do it, make sure to set a priority in modinfo.lua, whereat a high number means your modmain gets loaded first and your files override the other mods' files and a negative number means your mod loads last and your file overrides get ignored if necessary. Edited February 1, 2016 by Mobbstar Link to comment https://forums.kleientertainment.com/forums/topic/63588-mod-overrides/#findComment-715991 Share on other sites More sharing options...
MF99K Posted February 1, 2016 Author Share Posted February 1, 2016 2 hours ago, Mobbstar said: You can manipulate most Lua scripts using so-called Post-Init functions. You probably know "AddPrefabPostInit()" already. The rest can be seen in data/modutil.lua or in the API example mod. Mods can also contain a copy of a game file (must be in the same directory, e.g. "../scripts/prefabs"), which will be loaded instead of the original. If two mods do this, the game crashes, I think. So if you do it, make sure to set a priority in modinfo.lua, whereat a high number means your modmain gets loaded first and your files override the other mods' files and a negative number means your mod loads last and your file overrides get ignored if necessary. alright. Since one of my mods is supposed to configure Charlie's attack, sanity and frequency (so that people can make darkness easier for noobs, or harder for experienced players) and since the grue is a component and not a prefab, the only thing I can change is the attack value since it's defined by tuning, which I know how to override with mod configurations. If I reference self. values from grue.lua in the configuration settings, will it override correctly? or should I add and edit a grue component lua file within the mod folder? Link to comment https://forums.kleientertainment.com/forums/topic/63588-mod-overrides/#findComment-716014 Share on other sites More sharing options...
Mobbstar Posted February 1, 2016 Share Posted February 1, 2016 @mf99k You should be able to use the following (warning: "ThatFunction" is not real): AddComponentPostInit("grue",function(self) local oldfn = self.ThatFunction self:ThatFunction(...) --preedit oldfn(...) --postedit end end) Link to comment https://forums.kleientertainment.com/forums/topic/63588-mod-overrides/#findComment-716017 Share on other sites More sharing options...
MF99K Posted February 2, 2016 Author Share Posted February 2, 2016 17 hours ago, Mobbstar said: @mf99k You should be able to use the following (warning: "ThatFunction" is not real): AddComponentPostInit("grue",function(self) local oldfn = self.ThatFunction self:ThatFunction(...) --preedit oldfn(...) --postedit end end) So, in theory, I would replace "ThatFunction" with the function I want to configure. How would I apply the modconfigdata to this/is that what I put inside the (...)? Also, would this code go into modmain.lua? Link to comment https://forums.kleientertainment.com/forums/topic/63588-mod-overrides/#findComment-716346 Share on other sites More sharing options...
Mobbstar Posted February 2, 2016 Share Posted February 2, 2016 Just now, mf99k said: So, in theory, I would replace "ThatFunction" with the function I want to configure. How would I apply the modconfigdata to this/is that what I put inside the (...)? Also, would this code go into modmain.lua? Yes, "ThatFunction" can be replaced by an actual function name. You can get mod config data using GetModConfigData("name"), I recommend you save the data in a local variable. The (...) is a special thing in Lua which means it takes all arguments and just passes them on. If you want to use some of the arguments of "ThatFunction", you need to spell them all out (you can just copy the original ones). And yes, modmain.lua and modworldgenmain.lua are the only files that has these functions (not counting imported files, which are basically part of the parent file). Link to comment https://forums.kleientertainment.com/forums/topic/63588-mod-overrides/#findComment-716484 Share on other sites More sharing options...
MF99K Posted February 29, 2016 Author Share Posted February 29, 2016 On 2/2/2016 at 11:04 PM, Mobbstar said: Yes, "ThatFunction" can be replaced by an actual function name. You can get mod config data using GetModConfigData("name"), I recommend you save the data in a local variable. The (...) is a special thing in Lua which means it takes all arguments and just passes them on. If you want to use some of the arguments of "ThatFunction", you need to spell them all out (you can just copy the original ones). And yes, modmain.lua and modworldgenmain.lua are the only files that has these functions (not counting imported files, which are basically part of the parent file). I finally edited the mod to something I think will work, but Mod Tools doesn't seem to like how I set up the configuration code. I checked and double checked all the brackets and commas and I'm still getting the "modinfo is either missing or invalid" error. modinfo.lua Link to comment https://forums.kleientertainment.com/forums/topic/63588-mod-overrides/#findComment-728248 Share on other sites More sharing options...
Mobbstar Posted February 29, 2016 Share Posted February 29, 2016 I don't think TUNING is accessible from modinfo.lua Also, add compatibility tags for the base game modes! Link to comment https://forums.kleientertainment.com/forums/topic/63588-mod-overrides/#findComment-728363 Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now