Anonymous

Module:Items: Difference between revisions

From Melvor Idle
Added modifier list to getOtherItemBoxText
(Added Passive slot mention for passive items)
(Added modifier list to getOtherItemBoxText)
Line 9: Line 9:
local ItemData = mw.loadData('Module:Items/data')
local ItemData = mw.loadData('Module:Items/data')
local SkillData = mw.loadData('Module:Skills/data')
local SkillData = mw.loadData('Module:Skills/data')
local Constants = mw.loadData('Module:Constants/data')


local Constants = require('Module:Constants')
local Shared = require('Module:Shared')
local Shared = require('Module:Shared')
local Icons = require('Module:Icons')
local Icons = require('Module:Icons')
Line 199: Line 199:
   result = result..'\r\n|}'
   result = result..'\r\n|}'
   return result
   return result
end
function p.getEquipmentSlotName(id)
  for slotName, i in Shared.skpairs(Constants.equipmentSlot) do
    if i == id then
      return slotName
    end
  end
  return 'Invalid'
end
end


Line 214: Line 205:
   --For equipment, show the slot they go in
   --For equipment, show the slot they go in
   if item.equipmentSlot ~= nil then
   if item.equipmentSlot ~= nil then
     result = result.."\r\n|-\r\n|'''Equipment Slot:''' "..p.getEquipmentSlotName(item.equipmentSlot)
     result = result.."\r\n|-\r\n|'''Equipment Slot:''' "..Constants.getEquipmentSlotName(item.equipmentSlot)
     if item.isPassiveItem then
     if item.isPassiveItem then
       result = result..', Passive'
       result = result..', Passive'
Line 237: Line 228:
   if item.prayerPoints ~= nil then
   if item.prayerPoints ~= nil then
     result = result.."\r\n|-\r\n|'''"..Icons.Icon({'Prayer', type='skill'}).." Points:''' "..item.prayerPoints
     result = result.."\r\n|-\r\n|'''"..Icons.Icon({'Prayer', type='skill'}).." Points:''' "..item.prayerPoints
  end
  --For items with modifiers, show what those are
  if item.modifiers ~= nil and Shared.tableCount(item.modifiers) > 0 then
    local modArray = {}
    for bonus, value in Shared.skpairs(item.modifiers) do
      table.insert(modArray, Constants.getModifierText(bonus, value, false))
    end
    result = result.."\r\n|-\r\n|'''Bonuses:'''\r\n"..table.concat(modArray, "<br/>")
   end
   end
   return result
   return result