Jump to content

Digable prefab?


Recommended Posts


        inst:AddComponent("workable")
        inst.components.workable:SetWorkAction(ACTIONS.DIG)
        inst.components.workable:SetOnFinishCallback(dig_up)
        inst.components.workable:SetWorkLeft(1)

You need to create the related "dig_up" function. Look at berry_bush prefab or grass prefab for example. Another example, stump for tree

 


    inst:AddComponent("workable")
    inst.components.workable:SetWorkAction(ACTIONS.DIG)
    inst.components.workable:SetOnFinishCallback(dig_up_stump)
    inst.components.workable:SetWorkLeft(1)

Related function


local function dig_up_stump(inst, chopper)
    inst.components.lootdropper:SpawnLootPrefab("log")
    inst:Remove()
end

Don't forget to add the drop to the prefab list of the item if it's a custom prefab. For example, if you want your "sandpile" to drop "sand", sand must be in

 

local prefabs =
{
    "twigs",
    "rocks",
    "sand",
}

 

Link to comment
Share on other sites

1 hour ago, Lumina said:


        inst:AddComponent("workable")
        inst.components.workable:SetWorkAction(ACTIONS.DIG)
        inst.components.workable:SetOnFinishCallback(dig_up)
        inst.components.workable:SetWorkLeft(1)

You need to create the related "dig_up" function. Look at berry_bush prefab or grass prefab for example. Another example, stump for tree

 



    inst:AddComponent("workable")
    inst.components.workable:SetWorkAction(ACTIONS.DIG)
    inst.components.workable:SetOnFinishCallback(dig_up_stump)
    inst.components.workable:SetWorkLeft(1)

Related function



local function dig_up_stump(inst, chopper)
    inst.components.lootdropper:SpawnLootPrefab("log")
    inst:Remove()
end

Don't forget to add the drop to the prefab list of the item if it's a custom prefab. For example, if you want your "sandpile" to drop "sand", sand must be in

 


local prefabs =
{
    "twigs",
    "rocks",
    "sand",
}

 

Thanks alot, i don't know why i didn't notice these line....swear to god i have checked berrybush/grass/twig prefab many times.....

Link to comment
Share on other sites

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
 Share

×
  • Create New...