Jump to content

Recommended Posts

I can tell you where you can find them, I don't know how to change them except for using the upvaluehacker as I don't know if the functions can be accessed otherwise.

Spoiler

function fns.OnItemRanOut(inst, data)
    if inst.components.inventory:GetEquippedItem(data.equipslot) == nil then
        local sameTool = inst.components.inventory:FindItem(function(item)
            return item.prefab == data.prefab and
                item.components.equippable ~= nil and
                item.components.equippable.equipslot == data.equipslot
        end)
        if sameTool ~= nil then
            inst.components.inventory:Equip(sameTool)
        end
    end
end

function fns.OnUmbrellaRanOut(inst, data)
    if inst.components.inventory:GetEquippedItem(data.equipslot) == nil then
        local sameTool = inst.components.inventory:FindItem(function(item)
            return item:HasTag("umbrella") and
                item.components.equippable ~= nil and
                item.components.equippable.equipslot == data.equipslot
        end)
        if sameTool ~= nil then
            inst.components.inventory:Equip(sameTool)
        end
    end
end

function fns.ArmorBroke(inst, data)
    if data.armor ~= nil then
        local sameArmor = inst.components.inventory:FindItem(function(item)
            return item.prefab == data.armor.prefab
        end)
        if sameArmor ~= nil then
            inst.components.inventory:Equip(sameArmor)
        end
    end
end
--------------------
local function RegisterMasterEventListeners(inst)
    inst:ListenForEvent("itemranout", fns.OnItemRanOut)
    inst:ListenForEvent("umbrellaranout", fns.OnUmbrellaRanOut)
    inst:ListenForEvent("armorbroke", fns.ArmorBroke)

in player_common.lua

 

  • Thanks 2

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