fmo080308 Posted December 16, 2016 Share Posted December 16, 2016 Anyone know how to add more than 1 workable component to an object? Like if my char equip a hammer, he can smash that object, if my char equip a shovel, he can dig it, and so on with axe/pickaxe? Link to comment https://forums.kleientertainment.com/forums/topic/72543-2-or-more-workables-on-an-object/ Share on other sites More sharing options...
halfrose Posted December 16, 2016 Share Posted December 16, 2016 14 hours ago, fmo080308 said: Anyone know how to add more than 1 workable component to an object? Like if my char equip a hammer, he can smash that object, if my char equip a shovel, he can dig it, and so on with axe/pickaxe? you just need to look into the axe_pickaxe lua, if you look into it you will find inst:AddComponent("tool") inst.components.tool:SetAction(ACTIONS.CHOP, 1.33) inst.components.tool:SetAction(ACTIONS.MINE, 1.33) and related. Link to comment https://forums.kleientertainment.com/forums/topic/72543-2-or-more-workables-on-an-object/#findComment-849311 Share on other sites More sharing options...
fmo080308 Posted December 16, 2016 Author Share Posted December 16, 2016 8 hours ago, halfrose said: you just need to look into the axe_pickaxe lua, if you look into it you will find inst:AddComponent("tool") inst.components.tool:SetAction(ACTIONS.CHOP, 1.33) inst.components.tool:SetAction(ACTIONS.MINE, 1.33) and related. Thank for your reply, I know how to make a tool that can do multiple actions, what i actually want is to make an object that can be digged up (by a shovel) and smashed (by a hammer) Link to comment https://forums.kleientertainment.com/forums/topic/72543-2-or-more-workables-on-an-object/#findComment-849452 Share on other sites More sharing options...
halfrose Posted December 16, 2016 Share Posted December 16, 2016 OHHH alright, sorry for misunderstanding well have you tried adding the two workables in the prefab? aka: inst.components.workable:SetWorkAction(ACTIONS.HAMMER) inst.components.workable:SetWorkAction(ACTIONS.DIG) to see what happens? Link to comment https://forums.kleientertainment.com/forums/topic/72543-2-or-more-workables-on-an-object/#findComment-849453 Share on other sites More sharing options...
Serpens Posted December 17, 2016 Share Posted December 17, 2016 the workable component only does save one action. So I fear this is not possible with normal game mechanics. Maybe you could add your own workable component that supports multiplay actions. But this could be complicated Link to comment https://forums.kleientertainment.com/forums/topic/72543-2-or-more-workables-on-an-object/#findComment-849480 Share on other sites More sharing options...
. . . Posted December 17, 2016 Share Posted December 17, 2016 (edited) Maybe you can have the workable object check what the closest player has equipped in their hand then make it do different stuff depending on what that closest player has equipped in their hand? Oops, didn't read the part where you want different actions for the object ... Edited December 17, 2016 by SuperDavid Link to comment https://forums.kleientertainment.com/forums/topic/72543-2-or-more-workables-on-an-object/#findComment-849511 Share on other sites More sharing options...
Narmor Posted January 13, 2017 Share Posted January 13, 2017 Have you found a solition for this problem? I need exactly the same functionality. I tried copying the "workable" component under a different name and addint that to the prefab as extra. I can now Hammer and Chop my Prefab (which is a Structure) but for some Reason the callbacks are not called. Im not shure if that is the fault of how the Stock actions work ("ACTIONS.CHOP") or if copying the "workable" component is not possible in such an easy matter. I will inquire this further, but if anyone else has done this already it would be nice to get a working snipped (I also looked for existing mods, that use such an approach, but it seems as if nobody else wants to do this.) inst:AddComponent("workable") inst.components.workable:SetWorkAction(ACTIONS.HAMMER) inst.components.workable:SetWorkLeft(2) inst.components.workable:SetOnFinishCallback(onhammered) inst.components.workable:SetOnWorkCallback(onhit) inst:AddComponent("sorterworkable") inst.components.sorterworkable:SetWorkAction(ACTIONS.CHOP) inst.components.sorterworkable:SetWorkLeft(1) inst.components.sorterworkable:SetOnWorkCallback(ontransformFinished) --TODO inst.components.sorterworkable:SetOnFinishCallback(ontransformFinished) --TODO =============================================================================================== local function ontransformFinished(inst, worker) print "HEEEEELOW" end Link to comment https://forums.kleientertainment.com/forums/topic/72543-2-or-more-workables-on-an-object/#findComment-857934 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