• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Trying to gathering item attributes to make a overall equipment power

ZuhmaR

New Member
Joined
Dec 6, 2022
Messages
2
Reaction score
0
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))
 
Back
Top