Jump to content

Recommended Posts

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.

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)

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?

 

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 :wilson_facepalm:...

Edited by SuperDavid

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

 

screenshot.PNG

screenshot2.PNG

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
  • Create New...