player_common.lua
function fns.ArmorBroke(inst, data) if data.armor ~= nil then local sameArmor = inst.components.inventory:FindItem(function(item) return item.prefab == data.armor.prefab and item.components.equippable ~= nil end) if sameArmor ~= nil then local force_ui_anim = data.armor.components.armor.keeponfinished inst.components.inventory:Equip(sameArmor, nil, nil, force_ui_anim) end end end
If another same armor (from a mod, or future update) is also broken and it is still equippable, this will cause an infinite loop.
Add a check.
function fns.ArmorBroke(inst, data) if data.armor ~= nil then local sameArmor = inst.components.inventory:FindItem(function(item) return item.prefab == data.armor.prefab and item.components.equippable ~= nil and item.components.armor ~= nil and item.components.armor:GetPercent() > 0 end) if sameArmor ~= nil then local force_ui_anim = data.armor.components.armor.keeponfinished inst.components.inventory:Equip(sameArmor, nil, nil, force_ui_anim) end end end
Steps to Reproduce
look at player_common.lua
-
1
There are no comments to display.
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 accountSign in
Already have an account? Sign in here.
Sign In Now