Anonymous

Module:Skills/Gathering: Difference between revisions

From Melvor Idle
Testing new format for getAxeTable based on v0.19.1 code format
(Moved getMiningOresTable here (from Module:Skills))
(Testing new format for getAxeTable based on v0.19.1 code format)
Line 3: Line 3:


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 Items = require('Module:Items')
local Items = require('Module:Items')
Line 10: Line 10:


function p.getAxeTable(frame)
function p.getAxeTable(frame)
  local axeArray = {}
  for i, upgrade in Shared.skpairs(SkillData.Shop.SkillUpgrades) do
    if Shared.contains(upgrade.name, 'Axe') then
      table.insert(axeArray, upgrade)
    end
  end
   local result = '{| class="wikitable sortable"'
   local result = '{| class="wikitable sortable"'
   result = result..'\r\n|- class="headerRow-0"'
   result = result..'\r\n|- class="headerRow-0"'
   result = result..'\r\n!colspan="2"|Name!!'..Icons.Icon({'Woodcutting', type='skill', notext=true})..' Level'
   result = result..'\r\n!colspan="2"|Name!!'..Icons.Icon({'Woodcutting', type='skill', notext=true})..' Level'
   result = result..'!!Bonus Speed!!Cost'
   result = result..'!!Cost!!Description'


   for i, axe in Shared.skpairs(SkillData.Woodcutting.Axes) do
   for i, axe in Shared.skpairs(axeArray) do
     if axe.cost ~= nil and axe.cost > 0 then
     result = result..'\r\n|-'
      result = result..'\r\n|-'
    result = result..'\r\n|data-sort-value="'..axe.name..'"|'..Icons.Icon({axe.name, type='upgrade', size='50', notext=true})
      result = result..'\r\n|data-sort-value="'..axe.name..'"|'..Icons.Icon({axe.name, type='upgrade', size='50', notext=true})
    result = result..'||[['..axe.name..']]'
      result = result..'||[['..axe.name..']]'
    local level = 1
      result = result..'||style="text-align:right"|'..axe.level
    if axe.unlockRequirements ~= nil and axe.unlockRequirements.skillLevel ~= nil then
       result = result..'||style="text-align:right" data-sort-value="'..axe.speed..'"|'..axe.speed..'%'
       --Gonna be lazy and assume there's only the one skill level and it's the one we care about
       result = result..'||style="text-align:right" data-sort-value="'..axe.cost..'"|'..Icons.GP(axe.cost)
       level = axe.unlockRequirements.skillLevel[1][2]
     end
     end
    result = result..'||style="text-align:right"|'..level
    result = result..'||style="text-align:right" data-sort-value="'..axe.cost.gp..'"|'..Icons.GP(axe.cost.gp)
    result = result..'||'..axe.description
   end
   end