Anonymous

Module:Items/UseTables: Difference between revisions

From Melvor Idle
Moved getSpellRunes to Magic.
(Added p.getSpellRunes)
(Moved getSpellRunes to Magic.)
Line 531: Line 531:


   return p._getSpellUseTable(item)
   return p._getSpellUseTable(item)
end
function p._getSpellRunes(spell)
  local result = ''
  for i, req in Shared.skpairs(spell.runesRequired) do
    local rune = Items.getItemByID(req.id)
    if i > 1 then result = result..', ' end
    result = result..Icons.Icon({rune.name, type='item', notext=true, qty=req.qty})
  end
  if spell.runesRequiredAlt ~= nil then
    result = result.."<br/>'''OR'''<br/>"
    for i, req in pairs(spell.runesRequiredAlt) do
      local rune = Items.getItemByID(req.id)
      if i > 1 then rowTxt = rowTxt..', ' end
      result = result..Icons.Icon({rune.name, type='item', notext=true, qty=req.qty})
    end
  end
  return result
end
function p.getSpellRunes(frame)
  local spellName = frame.args ~= nil and frame.args[1] or frame
  local spell = Magic.getSpell(spellName)
  if spell == nil then
    return "ERROR: No spell named "..spellName.." exists in the data module"
  end
  return p._getSpellRunes(spell)
end
end


return p
return p