Jump to content

Recommended Posts

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!

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)end
then use this function to load your custom prefabs.xml file
local 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/

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)end
then use this function to load your custom prefabs.xml file
local 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 by Alpaca's, Starving

[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

[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

Thanks, so you'll make an easy to use modding tool?

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
  • Create New...