Jump to content

Adding extra actions to the player


Recommended Posts

So I was commissioned to make a character who is a gathering dog and can dig holes without a shovel. I got the digging to work but then I had to make it so that the character only dug when their hands were empty (no tools or weapons equipped), so things like the Lazy Explorer and the Telelocator staff could still work.

Thing is I can't get the option to plant saplings and grass back.

I had used a code similar to the Werebeaver's shoveling and gnawing actions. I'll get the problematic function that I think might be stopping the character from being able to plant things.

local function SetTreasureWorker(inst, enable, self)
    if enable then
        if inst.components.worker == nil then
            inst:AddComponent("worker")
			inst.components.worker:SetAction(ACTIONS.DIG)
        end
    elseif inst.components.worker ~= nil then
        inst:RemoveComponent("worker")
    end
end

However, inst.components.worker:CanDoAction(ACTIONS.DIG) will let the player dig but have an effectiveness of 0. If I used inst:AddInherentAction(ACTIONS.DIG), It just wouldn't let the player dig with right click at all.

So I figured to maybe change what bind the digging is on, maybe to Alt+click which is normally the "Force Inspect" bind, and then add "deploy" as an action since that's what allows a sapling to be planted.

local TREASURE_CONTROL_FORCE_INSPECT_ACTIONS =
{
    "DIG", "DEPLOY"
}

Still, nothing has changed... and I'm not too certain what to do from here.

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