Anonymous

Module:Items/SourceTables/Sandbox: Difference between revisions

From Melvor Idle
Amend icon links & level derivation in buildRow()
m (Fix alt magic link)
(Amend icon links & level derivation in buildRow())
Line 792: Line 792:


--Set up function for adding rows
--Set up function for adding rows
local buildRow = function(source, level, minqty, qty, weight, totalWeight, expIcon)
local buildRow = function(source, level, levelNum, minqty, qty, weight, totalWeight, expIcon)
if minqty == nil then minqty = 1 end
if minqty == nil then minqty = 1 end
if expIcon == nil then expIcon = '' end
if expIcon == nil then expIcon = '' end
Line 800: Line 800:
table.insert(rowPart, '\r\n|style="text-align: left;"|'..source)
table.insert(rowPart, '\r\n|style="text-align: left;"|'..source)
-- Retrieve numeric level value for sorting, or remove anything between [[]]
-- Retrieve numeric level value for sorting, or remove anything between [[]]
local levelValue = level:match("Level (%d+)")
local levelValue = ''
if not levelValue then levelValue = level:match("%[%[.-%]%]%s*(%w+)$") or "" end
if levelNum ~= nil then
levelValue = tostring(levelNum)
else
levelValue = level:match('%[%[.-%]%]%s*(%w+)$') or ''
end
table.insert(rowPart, '\r\n|style="text-align: left;" data-sort-value="'..levelValue..'"|'..expIcon.. level)
table.insert(rowPart, '\r\n|style="text-align: left;" data-sort-value="'..levelValue..'"|'..expIcon.. level)
table.insert(rowPart, '\r\n|style="text-align: right;" data-sort-value="'..qty..'"|'..Shared.formatnum(minqty))
table.insert(rowPart, '\r\n|style="text-align: right;" data-sort-value="'..qty..'"|'..Shared.formatnum(minqty))
Line 846: Line 850:
table.insert(dropRows, {
table.insert(dropRows, {
source = Icons.Icon({iconName, type='monster'}),  
source = Icons.Icon({iconName, type='monster'}),  
level = '[[File:Combat.svg|25px|link=Monsters]] Level ' .. monsterLevel,
level = Icons.Icon({'Monsters', img='Combat', notext=true}) .. ' Level ' .. monsterLevel,
levelNum = monsterLevel,
minqty = drop.minQty,  
minqty = drop.minQty,  
qty = drop.maxQty,  
qty = drop.maxQty,  
Line 861: Line 866:
table.insert(dropRows, {
table.insert(dropRows, {
source = Icons.Icon({drop.name, type='poi'}),  
source = Icons.Icon({drop.name, type='poi'}),  
level = '[[File:Archaeology_(skill).svg|25px|link=Archaeology]] Level ' .. drop.level .. '('..drop.size..')',
level = Icons._SkillReq('Archaeology', drop.level) .. ' ('..drop.size..')',
levelNum = drop.level,
minqty = drop.minQty,  
minqty = drop.minQty,  
qty = drop.maxQty,  
qty = drop.maxQty,  
Line 942: Line 948:
source = sourceTxt,  
source = sourceTxt,  
level = Icons._SkillReq("Thieving", thiefRow.level),
level = Icons._SkillReq("Thieving", thiefRow.level),
levelNum = thiefRow.level,
minqty = thiefRow.minQty,  
minqty = thiefRow.minQty,  
qty = thiefRow.maxQty,  
qty = thiefRow.maxQty,  
Line 957: Line 964:
source = fishSource,  
source = fishSource,  
level = Icons._SkillReq("Fishing", 1),
level = Icons._SkillReq("Fishing", 1),
levelNum = 1,
minqty = 1,  
minqty = 1,  
qty = 1,  
qty = 1,  
Line 975: Line 983:
source = fishSource,  
source = fishSource,  
level = Icons._SkillReq("Fishing", 1),
level = Icons._SkillReq("Fishing", 1),
levelNum = 1,
minqty = fishItem.minQuantity,  
minqty = fishItem.minQuantity,  
qty = fishItem.maxQuantity,  
qty = fishItem.maxQuantity,  
Line 1,001: Line 1,010:
sourceTxt = '[[Mining#Superior Gems|Superior Gem]]'
sourceTxt = '[[Mining#Superior Gems|Superior Gem]]'
-- Superior gems can only be found with Mining 100 or above
-- Superior gems can only be found with Mining 100 or above
lv = Icons._SkillReq("Mining", 100)
lv = 100
else
else
sourceTxt = '[[Mining#Gems|Gem]]'
sourceTxt = '[[Mining#Gems|Gem]]'
-- Gems can only be found with any Mining level
-- Gems can only be found with any Mining level
lv = Icons._SkillReq("Mining", 1)
lv = 1
end
end
table.insert(dropRows, {
table.insert(dropRows, {
source = sourceTxt,  
source = sourceTxt,  
level = lv,
level = Icons._SkillReq('Mining', lv),
levelNum = lv,
minqty = thisGem.minQuantity,  
minqty = thisGem.minQuantity,  
qty = thisGem.maxQuantity,  
qty = thisGem.maxQuantity,  
Line 1,022: Line 1,032:
table.insert(dropRows, {
table.insert(dropRows, {
source = Icons.Icon({spell.name, type=Magic._getSpellIconType(spell)}),  
source = Icons.Icon({spell.name, type=Magic._getSpellIconType(spell)}),  
level = '[[File:Magic_(skill).svg|25px|link=Alternative_Magic]] Level ' .. spell.level,
level = Icons.Icon({'Alternative Magic', type='skill', img='Magic', notext=true}) .. ' Level ' .. spell.level,
levelNum = spell.level,
minqty = thisGem.minQuantity,  
minqty = thisGem.minQuantity,  
qty = thisGem.maxQuantity,
qty = thisGem.maxQuantity,
Line 1,049: Line 1,060:
end)
end)
for i, data in ipairs(dropRows) do
for i, data in ipairs(dropRows) do
table.insert(resultPart, buildRow(data.source, data.level, data.minqty, data.qty, data.weight, data.totalWeight, data.expIcon))
table.insert(resultPart, buildRow(data.source, data.level, data.levelNum, data.minqty, data.qty, data.weight, data.totalWeight, data.expIcon))
end
end


Line 1,231: Line 1,242:


function p.getItemSourceTables(frame)
function p.getItemSourceTables(frame)
-- Temp
local itemName = frame.args ~= nil and frame.args[1] or frame
--local args = frame:getParent().args
--local itemName = args.item or args[1]
local itemName = 'Diamond'
--local itemName = frame.args ~= nil and frame.args[1] or frame
local item = Items.getItem(itemName)
local item = Items.getItem(itemName)
if item == nil then
if item == nil then