Tesumoto Posted December 20, 2016 Share Posted December 20, 2016 How to create mod to edit wilson.lua?I want to be able to change the settings in the local master_postinit = function (inst) Link to comment https://forums.kleientertainment.com/forums/topic/72679-mod-for-wilson/ Share on other sites More sharing options...
MF99K Posted December 20, 2016 Share Posted December 20, 2016 Just now, Tezumoto said: How to create mod to edit wilson.lua?I want to be able to change the settings in the local master_postinit = function (inst) as in, you want to make a postinit that changes Wilson's stats? Or a mod that directly overwrites his lua file? what are you trying to do exactly? Link to comment https://forums.kleientertainment.com/forums/topic/72679-mod-for-wilson/#findComment-850887 Share on other sites More sharing options...
Tesumoto Posted December 20, 2016 Author Share Posted December 20, 2016 3 minutes ago, mf99k said: as in, you want to make a postinit that changes Wilson's stats? Or a mod that directly overwrites his lua file? what are you trying to do exactly? I want will replace the original file on the file from the mod. Or maybe someone can create a character mod based on Wilson? The second option is better, but it is difficult? Link to comment https://forums.kleientertainment.com/forums/topic/72679-mod-for-wilson/#findComment-850888 Share on other sites More sharing options...
MF99K Posted December 20, 2016 Share Posted December 20, 2016 Just now, Tezumoto said: I want will replace the original file on the file from the mod. Or maybe someone can create a character mod based on Wilson? The second option is better, but it is difficult? so you want to replace the wilson.lua file with a modded wilson.lua file? Then you wouldn't need to use a postinit since the game would overwrite the base file with the modded one automatically. Â what I'm asking when I ask what you're trying to do though, is what do you want the end result to be? depending on what exactly you're trying to get to happen, there are different ways to do it. Link to comment https://forums.kleientertainment.com/forums/topic/72679-mod-for-wilson/#findComment-850891 Share on other sites More sharing options...
Tesumoto Posted December 20, 2016 Author Share Posted December 20, 2016 (edited) 10 minutes ago, mf99k said: so you want to replace the wilson.lua file with a modded wilson.lua file? Then you wouldn't need to use a postinit since the game would overwrite the base file with the modded one automatically.  what I'm asking when I ask what you're trying to do though, is what do you want the end result to be? depending on what exactly you're trying to get to happen, there are different ways to do it. I want create a mod to add to wilson.lua new ability. And unlock one recipe in modmain.lua by code: AddPrefabPostInit("wilson", function(inst) if (inst.components and inst.components.builder) then inst.components.builder:UnlockRecipe("") end end)  Edited December 20, 2016 by Tezumoto Link to comment https://forums.kleientertainment.com/forums/topic/72679-mod-for-wilson/#findComment-850893 Share on other sites More sharing options...
MF99K Posted December 20, 2016 Share Posted December 20, 2016 ok, for starters, that code would only work for a character albert.lua file, which I'm assuming you know. I'm not sure what the ability is, and I haven't done much with postinits, but if you wanted wilson to automatically unlock the ability to craft shovels, and put "wilson" where it says "albert" it should probably work  Link to comment https://forums.kleientertainment.com/forums/topic/72679-mod-for-wilson/#findComment-850894 Share on other sites More sharing options...
Tesumoto Posted December 20, 2016 Author Share Posted December 20, 2016 (edited) 6 minutes ago, mf99k said: ok, for starters, that code would only work for a character albert.lua file, which I'm assuming you know. I'm not sure what the ability is, and I haven't done much with postinits, but if you wanted wilson to automatically unlock the ability to craft shovels, and put "wilson" where it says "albert" it should probably work  Code for wilson.lua and modmain.lua, I will be able to write. But how to create the foundation of mod? How to force the game to replace the original wilson.lua file on my file? Edited December 20, 2016 by Tezumoto Link to comment https://forums.kleientertainment.com/forums/topic/72679-mod-for-wilson/#findComment-850895 Share on other sites More sharing options...
MF99K Posted December 20, 2016 Share Posted December 20, 2016 download Don't Starve Mod Tools if you haven't already. (there's a tutorial for that somewhere on the forums) make a folder for your mod files to go in. download these files and put them in your mod folder modinfo.lua modmain.lua create a scripts folder inside that mod folder create a prefab folder inside the scripts folder put the modded wilson.lua file in there add your mod name, etc to modinfo.lua (I think) add your postinit code to modmain.lua use mod tools to upload your mod. if you don't have a mod preview image, put two hyphens in front of the line that asks for mod images. Link to comment https://forums.kleientertainment.com/forums/topic/72679-mod-for-wilson/#findComment-850899 Share on other sites More sharing options...
Tesumoto Posted December 20, 2016 Author Share Posted December 20, 2016 14 minutes ago, mf99k said: download Don't Starve Mod Tools if you haven't already. (there's a tutorial for that somewhere on the forums) make a folder for your mod files to go in. download these files and put them in your mod folder modinfo.lua modmain.lua create a scripts folder inside that mod folder create a prefab folder inside the scripts folder put the modded wilson.lua file in there add your mod name, etc to modinfo.lua (I think) add your postinit code to modmain.lua use mod tools to upload your mod. if you don't have a mod preview image, put two hyphens in front of the line that asks for mod images. Code in modmain.lua works, but the game does not use wilson.lua of mod. Link to comment https://forums.kleientertainment.com/forums/topic/72679-mod-for-wilson/#findComment-850903 Share on other sites More sharing options...
MF99K Posted December 20, 2016 Share Posted December 20, 2016 Just now, Tezumoto said: Code in modmain.lua works, but the game does not use wilson.lua of mod. hm. what changes did you make to it? could be that the game is having trouble recognizing it Link to comment https://forums.kleientertainment.com/forums/topic/72679-mod-for-wilson/#findComment-850904 Share on other sites More sharing options...
Tesumoto Posted December 20, 2016 Author Share Posted December 20, 2016 Just now, mf99k said: hm. what changes did you make to it? could be that the game is having trouble recognizing it I add only: local start_inv = {"torch"} and inst.components.combat.damagemultiplier = 1.25 Full code: local MakePlayerCharacter = require("prefabs/player_common") local assets = { Asset("SCRIPT", "scripts/prefabs/player_common.lua"), Asset("ANIM", "anim/beard.zip"), } local prefabs = { "beardhair", } -- Custom starting items local start_inv = {"torch"} local function common_postinit(inst) --bearded (from beard component) added to pristine state for optimization inst:AddTag("bearded") end local function OnResetBeard(inst) inst.AnimState:ClearOverrideSymbol("beard") end --tune the beard economy... local BEARD_DAYS = { 4, 8, 16 } local BEARD_BITS = { 1, 3, 9 } local function OnGrowShortBeard(inst) inst.AnimState:OverrideSymbol("beard", "beard", "beard_short") inst.components.beard.bits = BEARD_BITS[1] end local function OnGrowMediumBeard(inst) inst.AnimState:OverrideSymbol("beard", "beard", "beard_medium") inst.components.beard.bits = BEARD_BITS[2] end local function OnGrowLongBeard(inst) inst.AnimState:OverrideSymbol("beard", "beard", "beard_long") inst.components.beard.bits = BEARD_BITS[3] end local function master_postinit(inst) inst:AddComponent("beard") inst.components.beard.onreset = OnResetBeard inst.components.beard.prize = "beardhair" inst.components.beard:AddCallback(BEARD_DAYS[1], OnGrowShortBeard) inst.components.beard:AddCallback(BEARD_DAYS[2], OnGrowMediumBeard) inst.components.beard:AddCallback(BEARD_DAYS[3], OnGrowLongBeard) inst.components.combat.damagemultiplier = 1.25 end return MakePlayerCharacter("wilson", prefabs, assets, common_postinit, master_postinit) Â Link to comment https://forums.kleientertainment.com/forums/topic/72679-mod-for-wilson/#findComment-850906 Share on other sites More sharing options...
MF99K Posted December 20, 2016 Share Posted December 20, 2016 not sure exactly what's going on here, but the wilson code looks a bit short to me. I'd take a closer look but I need to get some sleep. good luck ^^ Link to comment https://forums.kleientertainment.com/forums/topic/72679-mod-for-wilson/#findComment-850909 Share on other sites More sharing options...
Tesumoto Posted December 20, 2016 Author Share Posted December 20, 2016 (edited) 2 minutes ago, mf99k said: not sure exactly what's going on here, but the wilson code looks a bit short to me. I'd take a closer look but I need to get some sleep. good luck ^^ I fixed) Forgot to add: return MakePlayerCharacter ( "wilson", prefabs, assets, common_postinit, master_postinit, start_inv) return MakePlayerCharacter ( "wilson", prefabs, assets, common_postinit, master_postinit, start_inv) Thank you for your help) Edited December 20, 2016 by Tezumoto Link to comment https://forums.kleientertainment.com/forums/topic/72679-mod-for-wilson/#findComment-850910 Share on other sites More sharing options...
WLP Posted January 29, 2023 Share Posted January 29, 2023 i agree Link to comment https://forums.kleientertainment.com/forums/topic/72679-mod-for-wilson/#findComment-1619508 Share on other sites More sharing options...
mxHanks Posted January 30, 2023 Share Posted January 30, 2023 I think using AddPrefabInit is a better choice Link to comment https://forums.kleientertainment.com/forums/topic/72679-mod-for-wilson/#findComment-1619538 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