Anonymous

Module:Pets: Difference between revisions

From Melvor Idle
403 bytes removed ,  12 June 2021
getPetBySkill: Remove obsolete function; getPetPageTable: Center align images
(Implement _getPetSkill(); Amend getPetTable()/getPetTableBySkill() to handle multiple pets)
(getPetBySkill: Remove obsolete function; getPetPageTable: Center align images)
Line 32: Line 32:
       result.id = i - 1
       result.id = i - 1
       result.skill = p._getPetSkill(result)
       result.skill = p._getPetSkill(result)
      break
    end
  end
  return result
end
function p.getPetBySkill(skillName)
  local result = nil
  local skillID = Skills.getSkillID(skillName)
  for i, pet in pairs(PetData.Pets) do
    --Deliberately excluding Ty. He knows what he did.
    if(skillID == pet.skill and pet.name ~= 'Ty') then
      result = Shared.clone(pet)
      --Make sure every pet has an id, and account for Lua being 1-index
      result.id = i - 1
       break
       break
     end
     end
Line 152: Line 137:


   return table.concat(resultPart, '\r\n')
   return table.concat(resultPart, '\r\n')
end
end


Line 212: Line 196:
   for i, thisPet in pairs(petList) do
   for i, thisPet in pairs(petList) do
     result = result..'\r\n|-\r\n|[['..thisPet.name..']]'
     result = result..'\r\n|-\r\n|[['..thisPet.name..']]'
     result = result..'||'..Icons.Icon({thisPet.name, size='60', type='pet', notext=true})
     result = result..'||style="text-align: center;"|'..Icons.Icon({thisPet.name, size='60', type='pet', notext=true})
     result = result..'||'..p._getPetSource(thisPet)
     result = result..'||'..p._getPetSource(thisPet)
     result = result..'||'..p._getPetEffect(thisPet)
     result = result..'||'..p._getPetEffect(thisPet)