Jump to content

How to detect character not holding any items?


Recommended Posts

Im trying to make it so that my character can charge with rmb when not holding an item but disable the ability to charge when holding an item. I used the same code that changed woodie's were actions and I could charge when "setspecialactions" was below "onbecamehuman" but now I dont get the option to charge at all. Any help is appreciated.


local function SetDefaultActions(inst)
inst.ActionStringOverride = nil
    if inst.components.playercontroller ~= nil then
        inst.components.playercontroller.actionbuttonoverride = nil
    end
    if inst.components.playeractionpicker ~= nil then
        inst.components.playeractionpicker.leftclickoverride = nil
        inst.components.playeractionpicker.rightclickoverride = nil
        inst.components.playeractionpicker.pointspecialactionsfn = nil
    end
        EnableReticule(inst, false)
end

local function SetSpecialActions(inst)
    inst.ActionStringOverride = nil
        if inst.components.playercontroller ~= nil then
            inst.components.playercontroller.actionbuttonoverride = Empty
        end
        if inst.components.playeractionpicker ~= nil then
            inst.components.playeractionpicker.rightclickoverride = ChargeRightClickPicker
            inst.components.playeractionpicker.pointspecialactionsfn = ChargePointSpecialActions
        end
        EnableReticule(inst, true)
    end

local master_postinit = function(inst)
	inst:ListenForEvent("unequipped", SetSpecialActions)
	inst:ListenForEvent("equipped", SetDefaultActions)
end

 

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