Module:Pets: Difference between revisions

1,608 bytes added ,  17 January 2021
getPetPageTable
(getPetSidebar Optional args)
(getPetPageTable)
Line 9: Line 9:
local Icons = require('Module:Icons')
local Icons = require('Module:Icons')
local Skills = require('Module:Skills')
local Skills = require('Module:Skills')
local Zones = require('Module:CombatAreas')




Line 91: Line 92:
   return result
   return result
end
end
function p.getPetPageTable()
  local result = ''
  local petList = {}
  local acquiredOverrides = {
    ['Ripper the Reindeer'] = '[[Events#Christmas_Event_2020|Christmas Event 2020]]',
  }
  local effectOverrides = {
    ['Ripper the Reindeer'] = 'None',
  }
  local acquired = nil
  local temp = nil
  for i, pet in pairs(PetData.Pets) do
    temp = Shared.clone(pet)
    if(effectOverrides[temp.name] ~= nil) then
      temp.description = effectOverrides[temp.name]
    end
    if(temp.name == 'Asura') then temp.acquiredBy = 'Slayer' end
    acquired = ''
    if(Skills.getSkillID(temp.acquiredBy) ~= nil) then
      acquired = 'skill'
    elseif Zones.getArea(temp.acquiredBy) ~= nil then
      acquired = 'slayer'
    end
    temp.type = acquired
    table.insert(petList, temp)
  end
  result = result..'{|class="wikitable lighttable"'
  result = result..'\r\n|-\r\n! Name !! Image !! Acquired From !! Effect'
  table.sort(petList, function(a, b)
                        return p.getPet(a.name).id < p.getPet(b.name).id
                      end)
  for i, thisPet in pairs(petList) do
    result = result..'\r\n|-\r\n|[['..thisPet.name..']]'
    result = result..'||'..Icons.Icon({thisPet.name, size='60', type='pet', notext=true})
    if acquiredOverrides[thisPet.name] ~= nil then
      result = result..'||'..acquiredOverrides[thisPet.name]
    else
      result = result..'||'..Icons.Icon({thisPet.acquiredBy, type=thisPet.type})
    end
    result = result..'||'..thisPet.description
  end
  result = result..'\r\n|}'
  return result
end


return p
return p
285

edits