DarivenCZ Posted March 11, 2018 Share Posted March 11, 2018 I am doing a character mod and i would like to make my character unable to chop trees. Is it possible. Thanks for response Edit: Or drain sanity when he chops a tree, mabey this is better. Link to comment Share on other sites More sharing options...
FleurDuSoleil3 Posted March 15, 2018 Share Posted March 15, 2018 I'm unsure about both of those, but a workaround that wouldn't involve you having to take into consideration every iteration of every tree (take mushtrees, for example. They have three different states) in the game would be to simply make your character unable to equip an axe. local function onCantEquip(inst) if inst and inst.components.talker then inst.components.talker:Say("INSERT YOUR CHARACTER'S DIALOGUE HERE.") end end local oldEquip = GLOBAL.ACTIONS.EQUIP.fn GLOBAL.ACTIONS.EQUIP.fn = function(act) return (act.invobject.prefab ~= "axe") and oldEquip(act) or onCantEquip(act.doer) end Put that in your character's modmain and it should do the trick. Not quit what you asked for but it gets the same job done. Link to comment Share on other sites More sharing options...
DarivenCZ Posted March 18, 2018 Author Share Posted March 18, 2018 Thanks that will do. Edit: problem is that if it is picked from the ground it goes in the hand slot if nothing there. How do i make it so only my character can not equip it, becouse in curent state it does that even for wilson. I dont know if it was easier to just make him loose sanity when axe equiped. Link to comment Share on other sites More sharing options...
BraveChicken Posted March 18, 2018 Share Posted March 18, 2018 If you want your character to not be able to use the axe to chop down trees (But still be able to use it as a weapon) then you can simply add to your modmain.lua GetPlayer = GLOBAL.GetPlayer AddPrefabPostInit("axe", function(inst) if GetPlayer().prefab == "YourCharacterHere" then inst:RemoveComponent("tool") end end) However, you would need to do this for every tool in the game which the player can use to chop down trees (So also the golden axe, and the multitool) and if you don't want your character to be able to equip the axe at all then add this instead: GetPlayer = GLOBAL.GetPlayer AddPrefabPostInit("axe", function(inst) if GetPlayer().prefab == "YourCharacterHere" then inst:RemoveComponent("equippable") end end) And if you want your character to be losing sanity from chopping down trees then you can use this:(it's from "Ysulyan, the Nature Dragon" mod by Ysulyan) Add this to your character's prefab file. local function OnWork(inst,data) if data.target and data.target:HasTag("tree") and not data.target:HasTag("burnt") and not data.target:HasTag("stump") then inst.components.sanity:DoDelta(-TUNING.SANITY_SUPERTINY) if not inst.choppedrecently then inst.components.talker:Say("Put here what you want your character to say.") inst.choppedrecently = inst:DoTaskInTime(10,function(inst) inst.choppedrecently = nil end) end end end inst:ListenForEvent("working",OnWork) I hope that this can help you. And good luck with your mod! ^-^ Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.
Please be aware that the content of this thread may be outdated and no longer applicable.