Anonymous

Module:Pets: Difference between revisions

From Melvor Idle
Added new getPets function for use in the new ModifierTables module that's in progress
(Added override for Into the Mist specifically)
(Added new getPets function for use in the new ModifierTables module that's in progress)
(2 intermediate revisions by the same user not shown)
Line 47: Line 47:
       result.id = i - 1
       result.id = i - 1
       break
       break
    end
  end
  return result
end
function p.getPets(checkFunc)
  local result = {}
  for i, pet in Shared.skpairs(PetData.Pets) do
    if checkFunc(pet) then
      local newPet = Shared.clone(pet)
      newPet.id = i - 1
      table.insert(result, newPet)
     end
     end
   end
   end
Line 183: Line 195:
   local pet = p.getPetByID(dung.petID)
   local pet = p.getPetByID(dung.petID)
   if pet ~= nil then
   if pet ~= nil then
     result = "\r\n|-\r\n|'''Pet:'''<br/>"
     result = "\r\n|-\r\n|'''[[Pets#Boss Pets|Pet]]:'''<br/>"
     result = result..Icons.Icon({pet.name, type='pet'})
     result = result..Icons.Icon({pet.name, type='pet'})


Line 193: Line 205:
       dropChance = '1 in '..odds..' ('..Shared.round(100 / odds, 2, 2)..'%)'
       dropChance = '1 in '..odds..' ('..Shared.round(100 / odds, 2, 2)..'%)'
     end
     end
     result = result.."<br/>Drop Chance: "..dropChance
     result = result.."\r\n|-\r\n|'''Pet Drop Chance:'''<br/>"..dropChance
   end
   end