. . . Posted November 27, 2016 Share Posted November 27, 2016 (edited) Hello, I need help ... If somebody can help that'd be great ! So, the code I need help with is this.. mycharacter.lua Spoiler inst:ListenForEvent("equip", function(inst, data) local handslot = inst.components.inventory:GetEquippedItem(EQUIPSLOTS.HANDS) if handslot and not handslot.components.finiteuses then return end if inst.components.sanity:IsSane() then if handslot then handslot.forceful_tool = true end if handslot and not handslot.components.tool then handslot:AddComponent("tool") end if handslot and not handslot.components.tool:CanDoAction(ACTIONS.CHOP) then handslot.components.tool:SetAction(ACTIONS.CHOP) handslot.components.finiteuses:SetConsumption(ACTIONS.CHOP, 1) end if handslot and not handslot.components.tool:CanDoAction(ACTIONS.MINE) then handslot.components.tool:SetAction(ACTIONS.MINE) handslot.components.finiteuses:SetConsumption(ACTIONS.MINE, 1) end if handslot and not handslot.components.tool:CanDoAction(ACTIONS.HAMMER) then handslot.components.tool:SetAction(ACTIONS.HAMMER) handslot.components.finiteuses:SetConsumption(ACTIONS.HAMMER, 1) end else return end end) and this in modmain.lua Spoiler AddPlayerPostInit(function(inst, data) inst:ListenForEvent("equip", function(inst, data) local handslot = data.item if inst.prefab == "adam" and inst.replica.sanity:IsSane() then return end if handslot and handslot.components.tool and handslot.forceful_tool == true then --handslot:RemoveComponent("tool") handslot.components.tool:RemoveAction(ACTIONS.CHOP) end end) end) basically what i'm trying to do is when my character's insane I want him to be able to use any tool with durability as a pickaxe, hammer or axe the only problem's when he isn't using the tool I want to remove the actions from the tool then only my character can use them like that, so the playerpostinit in modmain.lua can do that..but it seems "handslot.components.tool:RemoveAction(ACTIONS.CHOP)" is not a real thing & removing component tool makes the tool completely useless... Is there a better way to achieve what i'm trying to do or is there something I can do to remove a certain action from a tool? I would appreciate any kind of help ! Thanks for reading my problem & have a great day/night! Edited November 27, 2016 by SuperDavid Link to comment Share on other sites More sharing options...
Aquaterion Posted November 27, 2016 Share Posted November 27, 2016 (edited) i think this would work, but its kinda hacky handslot.components.tool.actions[ACTIONS.CHOP] = nil handslot:RemoveTag(ACTIONS.CHOP.id.."_tool") Edited November 27, 2016 by Aquaterion Link to comment Share on other sites More sharing options...
. . . Posted November 27, 2016 Author Share Posted November 27, 2016 14 minutes ago, Aquaterion said: i think this would work It worked, thanks a lot man ! Link to comment 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