Lua:
local totalEquipmentPower = 0
local slots = {SLOT_HEAD, SLOT_NECKLACE, SLOT_BACKPACK, SLOT_ARMOR, SLOT_LEGS, SLOT_FEET, SLOT_RING, SLOT_WEAPON, SLOT_AMMO}
for _, slot in ipairs(slots) do
local item = player:getSlotItem(slot)
if item then
local itemName = item:getName() -- Added item name for easier debugging
local itemAttack = item:getAttack() or 0
local itemDefense = item:getDefense() or 0
print(string.format("Slot: %d - Item: %s - Attack: %d - Defense: %d", slot, itemName, itemAttack, itemDefense)) -- Debug statement to check item attributes
if not itemAttack or not itemDefense then -- Handle missing attributes
print(string.format("Error: Missing attribute(s) for item %s in slot %d", itemName, slot))
else
local itemPower = (itemAttack / MAX_ITEM_ATTACK) + (itemDefense / MAX_ITEM_DEFENSE)
totalEquipmentPower = totalEquipmentPower + itemPower
print(string.format("Slot: %d - Item: %s - Attack: %d - Defense: %d - Item Power: %.4f", slot, itemName, itemAttack, itemDefense, itemPower))
end
else
print(string.format("Slot: %d - No item equipped", slot))
end
end
print(string.format("Total Equipment Power: %.4f", totalEquipmentPower))