Anonymous

Module:Pets: Difference between revisions

From Melvor Idle
Use Constants.getModifierText() for pet effects
m (getPetPageTable: Add acquiredOverrides for Golbin Raid pets)
(Use Constants.getModifierText() for pet effects)
Line 4: Line 4:


local PetData = mw.loadData('Module:Pets/data')
local PetData = mw.loadData('Module:Pets/data')
local Constants = mw.loadData('Module:Constants/data')


local Shared = require( "Module:Shared" )
local Shared = require( "Module:Shared" )
local Constants = require('Module:Constants')
local Icons = require('Module:Icons')
local Icons = require('Module:Icons')
local Skills = require('Module:Skills')
local Skills = require('Module:Skills')
Line 49: Line 49:
   end
   end
   return result
   return result
end
function p._getPetEffect(pet)
  if pet.modifiers ~= nil then
    local effects = {}
    for effectName, effectValue in pairs(pet.modifiers) do
      table.insert(effects, Constants.getModifierText(effectName, effectValue, false))
    end
    return table.concat(effects, '\n\r')
  else
    return pet.description
  end
end
end


Line 74: Line 86:
   local name = (args.name ~= nil and args.name ~= '') and args.name or args[1]
   local name = (args.name ~= nil and args.name ~= '') and args.name or args[1]
   local pet = p.getPet(name)
   local pet = p.getPet(name)
   local effect = (args.effect ~= nil and args.effect ~= '') and args.effect or pet.description
   local effect = (args.effect ~= nil and args.effect ~= '') and args.effect or p._getPetEffect(pet)


   local source = nil
   local source = nil
Line 161: Line 173:
       result = result..'||'..Icons.Icon({thisPet.acquiredBy, type=thisPet.type})
       result = result..'||'..Icons.Icon({thisPet.acquiredBy, type=thisPet.type})
     end
     end
     result = result..'||'..thisPet.description
     result = result..'||'..p._getPetEffect(thisPet)
   end
   end
   result = result..'\r\n|}'
   result = result..'\r\n|}'