Module:Items/SourceTables/Sandbox: Difference between revisions

getItemSourceTables: Format monster combat level
m (Remove Source Type column in favour of Level column)
(getItemSourceTables: Format monster combat level)
 
(6 intermediate revisions by 2 users not shown)
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 799: Line 799:
table.insert(rowPart, '\r\n|-')
table.insert(rowPart, '\r\n|-')
table.insert(rowPart, '\r\n|style="text-align: left;"|'..source)
table.insert(rowPart, '\r\n|style="text-align: left;"|'..source)
--Weeding out brackets since they don't play nice with data-sort-value
-- Retrieve numeric level value for sorting, or remove anything between [[]]
local _, _, levelText = string.find(level, "%|([%a%s]+)%]")
local levelValue = ''
if levelText == nil then _, _, levelText = string.find(level, "%[%[([%a%s]+)%]") end
if levelNum ~= nil then
if levelText == nil then levelText = level end
levelValue = tostring(levelNum)
table.insert(rowPart, '\r\n|style="text-align: left;" data-sort-value="'..levelText..'"|'..expIcon.. level)
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: right;" data-sort-value="'..qty..'"|'..Shared.formatnum(minqty))
table.insert(rowPart, '\r\n|style="text-align: right;" data-sort-value="'..qty..'"|'..Shared.formatnum(minqty))
if qty ~= minqty then table.insert(rowPart, ' - '..Shared.formatnum(qty)) end
if qty ~= minqty then table.insert(rowPart, ' - '..Shared.formatnum(qty)) end
Line 847: 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 ' .. Shared.formatnum(monsterLevel),
levelNum = monsterLevel,
minqty = drop.minQty,  
minqty = drop.minQty,  
qty = drop.maxQty,  
qty = drop.maxQty,  
Line 862: 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 943: 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 958: 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 976: 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,002: 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,023: 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 = Icons._SkillReq("SkillData.Magic.name", 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,050: 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,232: 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