Alpaca's, Starving Posted March 5, 2013 Share Posted March 5, 2013 So I've looked on all the websites and have tried and tried again but I can't seem to grasp itI've made 3 mods so far 4th one coming soon but I can only edit the prefab files and don't have a clue how to edit the new mod system files 3: If any of you advance modders can give me your steam and we can disscuss that would be amazing! Link to comment https://forums.kleientertainment.com/forums/topic/11254-help-i-need-some-helpadvice-on-how-to-work-the-new-mod-system/ Share on other sites More sharing options...
Heavenfall Posted March 5, 2013 Share Posted March 5, 2013 Check out Frozen Ponds v2 for an example on how to include a prefab file from the /mods/ folder. Link to comment https://forums.kleientertainment.com/forums/topic/11254-help-i-need-some-helpadvice-on-how-to-work-the-new-mod-system/#findComment-102813 Share on other sites More sharing options...
Alpaca's, Starving Posted March 5, 2013 Author Share Posted March 5, 2013 Check out Frozen Ponds v2 for an example on how to include a prefab file from the /mods/ folder.I've looked and I still don't really get it that much, thanks for your help though Link to comment https://forums.kleientertainment.com/forums/topic/11254-help-i-need-some-helpadvice-on-how-to-work-the-new-mod-system/#findComment-102823 Share on other sites More sharing options...
Heavenfall Posted March 5, 2013 Share Posted March 5, 2013 First, in modmain include this (this is pretty much guaranteed to go into the vanilla game in next update by the way)-- custom functions to replace prefabs given by Bigfootkleiloadlua = GLOBAL.kleiloadluapackage = GLOBAL.packagelocal loadfn = function(modulename) local errmsg = "" local modulepath = string.gsub(modulename, "%.", "/") for path in string.gmatch(package.path, "([^;]+)") do local filename = string.gsub(path, "%?", modulepath) filename = string.gsub(filename, "\\", "/") local result = kleiloadlua(filename) if result then return result end errmsg = errmsg.."\n\tno file '"..filename.."' (checked with custom loader)" end return errmsg endGLOBAL.loadfile = function(filename) filename = string.gsub(filename, ".lua", "") filename = string.gsub(filename, "data/scripts/", "") return loadfn(filename)endthen use this function to load your custom prefabs.xml filelocal function HF_winterfrozenponds() loadfn( MODROOT.."prefabs.xml")endAddGamePostInit(HF_winterfrozenponds)[/spoiler]I want to replace the ponds prefab with my own, so in my prefabs.xml file I have only this<?xml version="1.0"?><Prefabs> <Defs> <Prefab name="pond" pathname="marsh/objects/pond" file="[B]mods\scripts\prefabs\pond.lua[/B]" desc=""> <Assets> <Asset type="ANIM" file="data/anim/marsh_tile.zip" flags="0"/> </Assets> <Deps> <Dep prefab="marsh_plant"/> <Dep prefab="fish"/> <Dep prefab="frog"/> <Dep prefab="mosquito"/> </Deps> </Prefab> </Defs></Prefabs>[/spoiler]notice the changed path to the file (bolded above) compared to what "pond" has in the vanilla prefabs.xml. Finally, I have placed my new pond file where the file path above says - under HF_winterfrozenponds/scripts/prefabs/ Link to comment https://forums.kleientertainment.com/forums/topic/11254-help-i-need-some-helpadvice-on-how-to-work-the-new-mod-system/#findComment-102829 Share on other sites More sharing options...
Alpaca's, Starving Posted March 5, 2013 Author Share Posted March 5, 2013 (edited) First, in modmain include this (this is pretty much guaranteed to go into the vanilla game in next update by the way)-- custom functions to replace prefabs given by Bigfootkleiloadlua = GLOBAL.kleiloadluapackage = GLOBAL.packagelocal loadfn = function(modulename) local errmsg = "" local modulepath = string.gsub(modulename, "%.", "/") for path in string.gmatch(package.path, "([^;]+)") do local filename = string.gsub(path, "%?", modulepath) filename = string.gsub(filename, "\\", "/") local result = kleiloadlua(filename) if result then return result end errmsg = errmsg.."\n\tno file '"..filename.."' (checked with custom loader)" end return errmsg endGLOBAL.loadfile = function(filename) filename = string.gsub(filename, ".lua", "") filename = string.gsub(filename, "data/scripts/", "") return loadfn(filename)endthen use this function to load your custom prefabs.xml filelocal function HF_winterfrozenponds() loadfn( MODROOT.."prefabs.xml")endAddGamePostInit(HF_winterfrozenponds)[/spoiler]I want to replace the ponds prefab with my own, so in my prefabs.xml file I have only this<?xml version="1.0"?><Prefabs> <Defs> <Prefab name="pond" pathname="marsh/objects/pond" file="[B]mods\scripts\prefabs\pond.lua[/B]" desc=""> <Assets> <Asset type="ANIM" file="data/anim/marsh_tile.zip" flags="0"/> </Assets> <Deps> <Dep prefab="marsh_plant"/> <Dep prefab="fish"/> <Dep prefab="frog"/> <Dep prefab="mosquito"/> </Deps> </Prefab> </Defs></Prefabs>[/spoiler]notice the changed path to the file (bolded above) compared to what "pond" has in the vanilla prefabs.xml. Finally, I have placed my new pond file where the file path above says - under HF_winterfrozenponds/scripts/prefabs/Thanks I'll give it agoEDIT: Still don't have a clue 3: Edited March 5, 2013 by Alpaca's, Starving Link to comment https://forums.kleientertainment.com/forums/topic/11254-help-i-need-some-helpadvice-on-how-to-work-the-new-mod-system/#findComment-102835 Share on other sites More sharing options...
WrathOf Posted March 8, 2013 Share Posted March 8, 2013 [MENTION=11096]Alpaca's, Starving[/MENTION]Ok, so your mods are currently not easy to handle with the new system without duplicating large chunks of code just to make your rather minor changes. :crushed:I'll post revised versions that at least use the override mechanism versus replacing the game files as you are doing now.The problem is that the prefabs involved are more complicated with various state changes and the prefab code is "black boxed" so unable to swap out their logic with ours easily. Hopefully this can be addressed soon. [MENTION=12700]Heavenfall[/MENTION]Please refrain from spreading that prefab loader code around....I really don't want us all trying to do that...I need to release a mod tool for you guys to share so we are all using the same mechanism until the game's code is fixed up to address it properly. thx Link to comment https://forums.kleientertainment.com/forums/topic/11254-help-i-need-some-helpadvice-on-how-to-work-the-new-mod-system/#findComment-104985 Share on other sites More sharing options...
Alpaca's, Starving Posted March 8, 2013 Author Share Posted March 8, 2013 [MENTION=11096]Alpaca's, Starving[/MENTION]Ok, so your mods are currently not easy to handle with the new system without duplicating large chunks of code just to make your rather minor changes. :crushed:I'll post revised versions that at least use the override mechanism versus replacing the game files as you are doing now.The problem is that the prefabs involved are more complicated with various state changes and the prefab code is "black boxed" so unable to swap out their logic with ours easily. Hopefully this can be addressed soon. [MENTION=12700]Heavenfall[/MENTION]Please refrain from spreading that prefab loader code around....I really don't want us all trying to do that...I need to release a mod tool for you guys to share so we are all using the same mechanism until the game's code is fixed up to address it properly. thxThanks, so you'll make an easy to use modding tool? Link to comment https://forums.kleientertainment.com/forums/topic/11254-help-i-need-some-helpadvice-on-how-to-work-the-new-mod-system/#findComment-105077 Share on other sites More sharing options...
WrathOf Posted March 8, 2013 Share Posted March 8, 2013 Oh that would be way too involved and time consuming....but I am trying to pull together some examples based on the current mods so you all at least have something to start out with. Link to comment https://forums.kleientertainment.com/forums/topic/11254-help-i-need-some-helpadvice-on-how-to-work-the-new-mod-system/#findComment-105082 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