4,951
edits
Falterfire (talk | contribs) (Added cooking, store items, & farming to item use table) |
Falterfire (talk | contribs) (Added a Spell Use table) |
||
Line 1,119: | Line 1,119: | ||
return a.item.name < b.item.name | return a.item.name < b.item.name | ||
end end) | end end) | ||
local spellUseTable = p._getSpellUseTable(item) | |||
local result = '' | local result = '' | ||
if Shared.tableCount(useArray) == 0 then | if Shared.tableCount(useArray) == 0 then | ||
return '' | if string.len(spellUseTable) > 0 then | ||
return '==Uses==\r\n==='..Icons.Icon({'Magic', type='skill', size='30'})..'===\r\n'..spellUseTable | |||
else | |||
return '' | |||
end | |||
end | end | ||
result = result..'{| class="wikitable sortable"' | result = result..'{| class="wikitable sortable"' | ||
Line 1,163: | Line 1,168: | ||
result = result..'\r\n|}' | result = result..'\r\n|}' | ||
if string.len(spellUseTable) > 0 then | |||
result = result..'\r\n==='..Icons.Icon({'Magic', type='skill', size='30'})..'===\r\n'..spellUseTable | |||
end | |||
return '==Uses==\r\n'..result | return '==Uses==\r\n'..result | ||
end | end | ||
Line 1,174: | Line 1,182: | ||
return p._getItemUseTable(item) | return p._getItemUseTable(item) | ||
end | |||
function p._getSpellUseTable(item) | |||
local spellList = Magic.getSpellsForRune(item.id) | |||
--Bail immediately if no spells are found | |||
if Shared.tableCount(spellList) == 0 then | |||
return '' | |||
end | |||
local result = '{|class="wikitable"\r\n!colspan="2"|Spell' | |||
result = result..'!!'..Icons.Icon({'Magic', type='skill', notext='true'})..' Level' | |||
result = result..'!!Type!!Description' | |||
result = result..'!!Runes' | |||
for i, spell in pairs(spellList) do | |||
local rowTxt = '\r\n|-\r\n|'..Icons.Icon({spell.name, type='spell', notext=true, size=50}) | |||
rowTxt = rowTxt..'||'..spell.magicLevelRequired..'||'..Magic.getSpellTypeLink(spell.type) | |||
if spell.type == 'Spells' then | |||
rowTxt = rowTxt..'||Combat spell with a max hit of '..(spell.maxHit * 10) | |||
else | |||
rowTxt = rowTxt..'||'..spell.description | |||
end | |||
rowTxt = rowTxt..'||style="text-align:center"|' | |||
for i, req in pairs(spell.runesRequired) do | |||
local rune = p.getItemByID(req.id) | |||
if i > 1 then rowTxt = rowTxt..', ' end | |||
rowTxt = rowTxt..Icons.Icon({rune.name, type='item', notext=true, qty=req.qty}) | |||
end | |||
if spell.runesRequiredAlt ~= nil then | |||
rowTxt = rowTxt.."<br/>'''OR'''<br/>" | |||
for i, req in pairs(spell.runesRequiredAlt) do | |||
local rune = p.getItemByID(req.id) | |||
if i > 1 then rowTxt = rowTxt..', ' end | |||
rowTxt = rowTxt..Icons.Icon({rune.name, type='item', notext=true, qty=req.qty}) | |||
end | |||
end | |||
result = result..rowTxt | |||
end | |||
--Add the table end and add the table to the result string | |||
result = result..'\r\n|}' | |||
return result | |||
end | |||
function p.getSpellUseTable(frame) | |||
local itemName = frame.args ~= nil and frame.args[1] or frame | |||
local item = p.getItem(itemName) | |||
if item == nil then | |||
return "ERROR: No item named "..itemName.." exists in the data module" | |||
end | |||
return p._getSpellUseTable(item) | |||
end | end | ||