Module:Items/SourceTables: Difference between revisions

Undo revision 46110 by Auron956 (talk)
(Update for v0.21)
(Undo revision 46110 by Auron956 (talk))
Tag: Undo
Line 4: Line 4:
local ItemData = mw.loadData('Module:Items/data')
local ItemData = mw.loadData('Module:Items/data')
local SkillData = mw.loadData('Module:Skills/data')
local SkillData = mw.loadData('Module:Skills/data')
local Constants = mw.loadData('Module:Constants/data')


local Constants = require('Module:Constants')
local Shared = require('Module:Shared')
local Shared = require('Module:Shared')
local Magic = require('Module:Magic')
local Magic = require('Module:Magic')
Line 82: Line 82:
     skill = 'Herblore'
     skill = 'Herblore'
     req = item.herbloreReq
     req = item.herbloreReq
     --Currently using 'masteryID' as shorthand to find details, could be a better method
     --Currently using 'herbloreMasteryID' as shorthand to find details, could be a better method
     local potionID = item.masteryID[2]
     local potionID = item.herbloreMasteryID
     local potionData = SkillData.Herblore.ItemData[potionID + 1]
     local potionData = SkillData.Herblore.ItemData[potionID + 1]
     lvl = potionData.herbloreLevel
     lvl = potionData.herbloreLevel
Line 90: Line 90:
     table.insert(tables, p.buildCreationTable(skill, lvl, xp, req, qty, time))
     table.insert(tables, p.buildCreationTable(skill, lvl, xp, req, qty, time))
   end
   end
   if item.masteryID ~= nil and item.masteryID[1] == 4 then
   if item.miningID ~= nil then
     skill = 'Mining'
     skill = 'Mining'
     lvl = SkillData.Mining.Rocks[item.masteryID[2] + 1].level
     lvl = SkillData.Mining.Rocks[item.masteryID[2] + 1].level
Line 184: Line 184:
           local item = Items.getItemByID(cost.id)
           local item = Items.getItemByID(cost.id)
           if item.type ~= 'Shard' then
           if item.type ~= 'Shard' then
             local sellPrice = math.max(item.sellsFor, 20)
             local sellPrice = item.sellsFor
            if sellPrice < 20 then sellPrice = 20 end
             table.insert(nonShardArray, Icons.Icon({item.name, type='item', notext=true, qty=math.max(1, math.floor(recipeGPCost / sellPrice))}))
             table.insert(nonShardArray, Icons.Icon({item.name, type='item', notext=true, qty=math.max(1, math.floor(recipeGPCost / sellPrice))}))
           end
           end
Line 207: Line 208:
     table.insert(tables, p.buildAltMagicTable('Just Learning'))
     table.insert(tables, p.buildAltMagicTable('Just Learning'))
   elseif item.name == 'Bones' then
   elseif item.name == 'Bones' then
     table.insert(tables, p.buildAltMagicTable('Bone Offering'))
     table.insert(tables, p.buildAltMagicTable('Bone Offering'))
   elseif item.name == 'Holy Dust' then
   elseif item.name == 'Holy Dust' then
     table.insert(tables, p.buildAltMagicTable('Blessed Offering'))
     table.insert(tables, p.buildAltMagicTable('Blessed Offering'))
Line 267: Line 268:
   if specialReq ~= nil then result = result..'<br/>'..specialReq end
   if specialReq ~= nil then result = result..'<br/>'..specialReq end


   if req ~= nil then
   if req ~= nil then  
     result = result..'\r\n|-\r\n!style="text-align: right;"|Materials\r\n|'
     result = result..'\r\n|-\r\n!style="text-align: right;"|Materials\r\n|'
     if type(req) == 'table' then
     if type(req) == 'table' then
Line 301: Line 302:
     return "ERROR: No item named "..itemName.." exists in the data module[[Category:Pages with script errors]]"
     return "ERROR: No item named "..itemName.." exists in the data module[[Category:Pages with script errors]]"
   end
   end
 
 
   return p._getCreationTable(item)
   return p._getCreationTable(item)
end
end
Line 345: Line 346:
         --If this is a boss then we actually are completing dungeons for this and need to figure out which one
         --If this is a boss then we actually are completing dungeons for this and need to figure out which one
         for j, dung in pairs(areaList) do
         for j, dung in pairs(areaList) do
           if string.len(dungeonStr) > 0 then
           if string.len(dungeonStr) > 0 then  
             dungeonStr = dungeonStr..','
             dungeonStr = dungeonStr..','
           else
           else
Line 482: Line 483:


   --MineCheck:
   --MineCheck:
   if item.masteryID ~= nil and item.masteryID[1] == 4 then
   if item.miningID ~= nil then
     table.insert(lineArray, Icons._SkillReq("Mining", SkillData.Mining.Rocks[item.masteryID[2] + 1].level))
     table.insert(lineArray, Icons._SkillReq("Mining", SkillData.Mining.Rocks[item.masteryID[2] + 1].level))
   end
   end
Line 494: Line 495:


   --HerbCheck:
   --HerbCheck:
   if item.masteryID ~= nil and item.masteryID[1] == 19 then
   if item.herbloreMasteryID ~= nil then
     local potionData = SkillData.Herblore.ItemData[item.masteryID[2] + 1].herbloreLevel
     local potionData = SkillData.Herblore.ItemData[item.herbloreMasteryID + 1].herbloreLevel
     table.insert(lineArray, Icons._SkillReq("Herblore", potionData))
     table.insert(lineArray, Icons._SkillReq("Herblore", potionData))
   end
   end
Line 562: Line 563:


   --Tokens are from the appropriate skill
   --Tokens are from the appropriate skill
   if item.isToken and item.skill ~= nil then
   if item.isToken then
    table.insert(lineArray, Icons._SkillReq(Constants.getSkillName(item.skill), 1))
    for skill, id in pairs(Constants.skill) do
      if id == item.skill then
        table.insert(lineArray, Icons._SkillReq(skill, 1))
      end
    end
   end
   end


Line 593: Line 598:
   local asList = false
   local asList = false
   local addCategories = false
   local addCategories = false
   if frame.args ~= nil then
   if frame.args ~= nil then  
     asList = frame.args.asList ~= nil and frame.args.asList ~= '' and frame.args.asList ~= 'false'
     asList = frame.args.asList ~= nil and frame.args.asList ~= '' and frame.args.asList ~= 'false'
     addCategories = frame.args.addCategories ~= nil and frame.args.addCategories ~= '' and frame.args.addCategories ~= 'false'
     addCategories = frame.args.addCategories ~= nil and frame.args.addCategories ~= '' and frame.args.addCategories ~= 'false'
Line 764: Line 769:
   if Shared.tableCount(dropRows) == 0 then return '' end
   if Shared.tableCount(dropRows) == 0 then return '' end


   table.sort(dropRows, function(a, b)
   table.sort(dropRows, function(a, b)  
                         if a.weight / a.totalWeight == b.weight / b.totalWeight then
                         if a.weight / a.totalWeight == b.weight / b.totalWeight then
                           return a.minqty + a.qty > b.minqty + b.qty
                           return a.minqty + a.qty > b.minqty + b.qty
Line 892: Line 897:


   local creationTable = p._getCreationTable(item)
   local creationTable = p._getCreationTable(item)
   if string.len(creationTable) > 0 then
   if string.len(creationTable) > 0 then  
     if string.len(result) > 0 then result = result..'\r\n' end
     if string.len(result) > 0 then result = result..'\r\n' end
     result = result..'===Creation===\r\n'..creationTable
     result = result..'===Creation===\r\n'..creationTable  
   end
   end


Line 931: Line 936:
   result = result..'!colspan="2"|Item\r\n! Passive\r\n'
   result = result..'!colspan="2"|Item\r\n! Passive\r\n'


   local itemArray = Items.getItems(function(item) return item.validSlots ~= nil and Shared.contains(item.validSlots, 'Passive') end)
   local itemArray = Items.getItems(function(item) return item.isPassiveItem and true or false end)


   table.sort(itemArray, function(a, b) return a.id < b.id end)
   table.sort(itemArray, function(a, b) return a.id < b.id end)
Line 940: Line 945:
     result = result..'| '..item.description..'\r\n'
     result = result..'| '..item.description..'\r\n'
   end
   end
 
 
   result = result..'|}'
   result = result..'|}'