Module:Items/SourceTables/Sandbox: Difference between revisions

m
Remove Source Type column in favour of Level column
m (Fix incorrect thieving level requirement)
m (Remove Source Type column in favour of Level column)
Line 789: Line 789:
table.insert(resultPart, '{| class="wikitable sortable stickyHeader"')
table.insert(resultPart, '{| class="wikitable sortable stickyHeader"')
table.insert(resultPart, '\r\n|- class="headerRow-0"')
table.insert(resultPart, '\r\n|- class="headerRow-0"')
table.insert(resultPart, '\r\n!Source!!Source Type!!Level!!Quantity!!colspan="2"|Chance')
table.insert(resultPart, '\r\n!Source!!Level!!Quantity!!colspan="2"|Chance')


--Set up function for adding rows
--Set up function for adding rows
local buildRow = function(source, type, level, minqty, qty, weight, totalWeight, expIcon)
local buildRow = function(source, level, 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)
--Weeding out brackets since they don't play nice with data-sort-value
--Weeding out brackets since they don't play nice with data-sort-value
local _, _, typeText = string.find(type, "%|([%a%s]+)%]")
local _, _, levelText = string.find(level, "%|([%a%s]+)%]")
if typeText == nil then _, _, typeText = string.find(type, "%[%[([%a%s]+)%]") end
if levelText == nil then _, _, levelText = string.find(level, "%[%[([%a%s]+)%]") end
if typeText == nil then typeText = type end
if levelText == nil then levelText = level end
table.insert(rowPart, '\r\n|style="text-align: left;" data-sort-value="'..typeText..'"|'..expIcon..type)
table.insert(rowPart, '\r\n|style="text-align: left;" data-sort-value="'..levelText..'"|'..expIcon.. level)
table.insert(rowPart, '\r\n|' ..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 848: Line 847:
table.insert(dropRows, {
table.insert(dropRows, {
source = Icons.Icon({iconName, type='monster'}),  
source = Icons.Icon({iconName, type='monster'}),  
type = '[[Monster]]', minqty = drop.minQty,
level = '[[File:Combat.svg|25px|link=Monsters]] Level ' .. monsterLevel,
level = '[[File:Combat.svg|25px|link=Combat]] Level ' .. monsterLevel,
minqty = drop.minQty,  
qty = drop.maxQty,  
qty = drop.maxQty,  
weight = drop.dropWt,  
weight = drop.dropWt,  
Line 863: Line 862:
table.insert(dropRows, {
table.insert(dropRows, {
source = Icons.Icon({drop.name, type='poi'}),  
source = Icons.Icon({drop.name, type='poi'}),  
type = '[[Archaeology|Dig Site]] ('..drop.size..')',
level = '[[File:Archaeology_(skill).svg|25px|link=Archaeology]] Level ' .. drop.level .. '('..drop.size..')',
level = Icons._SkillReq("Archaeology", drop.level),
minqty = drop.minQty,  
minqty = drop.minQty,  
qty = drop.maxQty,  
qty = drop.maxQty,  
Line 879: Line 877:
table.insert(dropRows, {
table.insert(dropRows, {
source = Icons.Icon({dungeon.name, type='dungeon'}),  
source = Icons.Icon({dungeon.name, type='dungeon'}),  
type = '[[Dungeon]]',
level = '[[Dungeon]]',
level = nil,
minqty = 1,  
minqty = 1,  
qty = 1,  
qty = 1,  
Line 895: Line 892:
table.insert(dropRows, {
table.insert(dropRows, {
source = sourceTxt,  
source = sourceTxt,  
type = '[[Dungeon]]',
level = '[[Dungeon]]',
level = nil,
minqty = 1,  
minqty = 1,  
qty = 1,  
qty = 1,  
Line 925: Line 921:
table.insert(dropRows, {
table.insert(dropRows, {
source = sourceTxt,  
source = sourceTxt,  
type = '[[Chest]]',
level = '[[Chest]]',
level = nil,
minqty = minQty,  
minqty = minQty,  
qty = maxQty,  
qty = maxQty,  
Line 947: Line 942:
table.insert(dropRows, {
table.insert(dropRows, {
source = sourceTxt,  
source = sourceTxt,  
type = Icons.Icon({SkillData.Thieving.name, type='skill'}),
level = Icons._SkillReq("Thieving", thiefRow.level),
level = Icons._SkillReq("Thieving", thiefRow.level),
minqty = thiefRow.minQty,  
minqty = thiefRow.minQty,  
Line 963: Line 957:
table.insert(dropRows, {
table.insert(dropRows, {
source = fishSource,  
source = fishSource,  
type = fishType,
level = Icons._SkillReq("Fishing", 1),
level = Icons._SkillReq("Fishing", 1),
minqty = 1,  
minqty = 1,  
Line 982: Line 975:
table.insert(dropRows, {
table.insert(dropRows, {
source = fishSource,  
source = fishSource,  
type = fishType,
level = Icons._SkillReq("Fishing", 1),
level = Icons._SkillReq("Fishing", 1),
minqty = fishItem.minQuantity,  
minqty = fishItem.minQuantity,  
Line 1,003: Line 995:
end
end
if thisGem ~= nil then
if thisGem ~= nil then
local mineType = Icons.Icon({SkillData.Mining.name, type='skill'})
local expIcon = ''
local expIcon = ''
local sourceTxt
local sourceTxt
Line 1,019: Line 1,010:
table.insert(dropRows, {
table.insert(dropRows, {
source = sourceTxt,  
source = sourceTxt,  
type = mineType,
level = lv,
level = lv,
minqty = thisGem.minQuantity,  
minqty = thisGem.minQuantity,  
Line 1,028: Line 1,018:
-- Check for Alt. Magic spells also
-- Check for Alt. Magic spells also
local magicType = Icons.Icon({SkillData.Magic.name, type = 'skill'})
local producesKey = (gemKey == 'randomGems' and 'RandomGem') or 'RandomSuperiorGem'
local producesKey = (gemKey == 'randomGems' and 'RandomGem') or 'RandomSuperiorGem'
for j, spell in ipairs(Magic.getSpellsBySpellBook('altMagic')) do
for j, spell in ipairs(Magic.getSpellsBySpellBook('altMagic')) do
Line 1,034: Line 1,023:
table.insert(dropRows, {
table.insert(dropRows, {
source = Icons.Icon({spell.name, type=Magic._getSpellIconType(spell)}),  
source = Icons.Icon({spell.name, type=Magic._getSpellIconType(spell)}),  
type = magicType,
level = Icons._SkillReq("SkillData.Magic.name", spell.level),
level = Icons._SkillReq("Magic", spell.level),
minqty = thisGem.minQuantity,  
minqty = thisGem.minQuantity,  
qty = thisGem.maxQuantity,
qty = thisGem.maxQuantity,
Line 1,053: Line 1,041:
if a.weight / a.totalWeight == b.weight / b.totalWeight then
if a.weight / a.totalWeight == b.weight / b.totalWeight then
if a.minqty + a.qty == b.minqty + b.qty then
if a.minqty + a.qty == b.minqty + b.qty then
return (a.type == b.type and a.source < b.source) or a.type < b.type
return (a.level == b.level and a.source < b.source) or a.level < b.level
else
else
return a.minqty + a.qty > b.minqty + b.qty
return a.minqty + a.qty > b.minqty + b.qty
Line 1,062: Line 1,050:
end)
end)
for i, data in ipairs(dropRows) do
for i, data in ipairs(dropRows) do
table.insert(resultPart, buildRow(data.source, data.type, data.level, data.minqty, data.qty, data.weight, data.totalWeight, data.expIcon))
table.insert(resultPart, buildRow(data.source, data.level, data.minqty, data.qty, data.weight, data.totalWeight, data.expIcon))
end
end


2,875

edits