GreenDevil Posted July 29, 2022 Share Posted July 29, 2022 hey guys, i am trying to add a feature where my character can chop trees and mine stones without an item but I am unsure on how to do it, any help would be appreciated. Link to comment https://forums.kleientertainment.com/forums/topic/142233-how-can-i-make-my-character-chop-trees-and-mine-stones-without-an-item/ Share on other sites More sharing options...
Bumber64 Posted July 30, 2022 Share Posted July 30, 2022 Try looking at scripts/prefabs/woodie.lua. His werebeaver form can chop, mine, and dig. Link to comment https://forums.kleientertainment.com/forums/topic/142233-how-can-i-make-my-character-chop-trees-and-mine-stones-without-an-item/#findComment-1590357 Share on other sites More sharing options...
GreenDevil Posted July 30, 2022 Author Share Posted July 30, 2022 4 hours ago, Bumber64 said: Try looking at scripts/prefabs/woodie.lua. His werebeaver form can chop, mine, and dig. I did but I do nbot know how to add to my code with out the form. Link to comment https://forums.kleientertainment.com/forums/topic/142233-how-can-i-make-my-character-chop-trees-and-mine-stones-without-an-item/#findComment-1590417 Share on other sites More sharing options...
Bumber64 Posted July 30, 2022 Share Posted July 30, 2022 (edited) It's applied using this code: if inst.components.playercontroller ~= nil then inst.components.playercontroller.actionbuttonoverride = BeaverActionButton end if inst.components.playeractionpicker ~= nil then inst.components.playeractionpicker.leftclickoverride = BeaverLeftClickPicker inst.components.playeractionpicker.rightclickoverride = BeaverRightClickPicker inst.components.playeractionpicker.pointspecialactionsfn = nil end EnableReticule(inst, false) You need to put something like that in your character file, after renaming and modifying the beaver code. I think you also need this code, too: inst:AddComponent("worker") inst.components.worker:SetAction(ACTIONS.CHOP, 1) inst.components.worker:SetAction(ACTIONS.MINE, 1) 1 is the standard rate for tools. You could use 2 or 0.5 to make it twice or half as effective. Beaver also includes ACTIONS.DIG and ACTIONS.HAMMER. (You probably don't want hammer.) Edited July 30, 2022 by Bumber64 Link to comment https://forums.kleientertainment.com/forums/topic/142233-how-can-i-make-my-character-chop-trees-and-mine-stones-without-an-item/#findComment-1590429 Share on other sites More sharing options...
GreenDevil Posted July 30, 2022 Author Share Posted July 30, 2022 11 hours ago, Bumber64 said: It's applied using this code: if inst.components.playercontroller ~= nil then inst.components.playercontroller.actionbuttonoverride = BeaverActionButton end if inst.components.playeractionpicker ~= nil then inst.components.playeractionpicker.leftclickoverride = BeaverLeftClickPicker inst.components.playeractionpicker.rightclickoverride = BeaverRightClickPicker inst.components.playeractionpicker.pointspecialactionsfn = nil end EnableReticule(inst, false) You need to put something like that in your character file, after renaming and modifying the beaver code. I think you also need this code, too: inst:AddComponent("worker") inst.components.worker:SetAction(ACTIONS.CHOP, 1) inst.components.worker:SetAction(ACTIONS.MINE, 1) 1 is the standard rate for tools. You could use 2 or 0.5 to make it twice or half as effective. Beaver also includes ACTIONS.DIG and ACTIONS.HAMMER. (You probably don't want hammer.) how much of the beaver code do i have to rename and modify?? Link to comment https://forums.kleientertainment.com/forums/topic/142233-how-can-i-make-my-character-chop-trees-and-mine-stones-without-an-item/#findComment-1590568 Share on other sites More sharing options...
GreenDevil Posted July 31, 2022 Author Share Posted July 31, 2022 bump Link to comment https://forums.kleientertainment.com/forums/topic/142233-how-can-i-make-my-character-chop-trees-and-mine-stones-without-an-item/#findComment-1590734 Share on other sites More sharing options...
Bumber64 Posted August 1, 2022 Share Posted August 1, 2022 Commented code is for if you want to be able to dig (considering you'll be leaving stumps): local function LeftClickPicker(inst, target) if target and target ~= inst then for i, v in ipairs({"CHOP", "MINE"}) do if target:HasTag(v.."_workable") then return inst.components.playeractionpicker:SortActionList({ ACTIONS[v] }, target, nil) or nil, true end end end return nil, true end --[[ local function RightClickPicker(inst, target) return target and target ~= inst and ( target:HasTag("DIG_workable") and inst.components.playeractionpicker:SortActionList({ ACTIONS.DIG }, target, nil) ) or nil, true end --]] local function setPickers(inst) if inst.components.playeractionpicker then inst.components.playeractionpicker.leftclickoverride = LeftClickPicker --inst.components.playeractionpicker.rightclickoverride = RightClickPicker end end This goes inside your player fn: inst:AddComponent("worker") inst.components.worker:SetAction(ACTIONS.CHOP, 1) inst.components.worker:SetAction(ACTIONS.MINE, 1) --inst.components.worker:SetAction(ACTIONS.DIG, 1) inst:ListenForEvent("setowner", setPickers) Link to comment https://forums.kleientertainment.com/forums/topic/142233-how-can-i-make-my-character-chop-trees-and-mine-stones-without-an-item/#findComment-1590884 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