Differenze tra le versioni di "Modulo:PokémonData"

Adding getShortType to PokémonData *** sovrascritto il testo esistente ***
(Internal updates *** sovrascritto il testo esistente ***)
(Adding getShortType to PokémonData *** sovrascritto il testo esistente ***)
 
 
Returns a Pokémon's type (specified by the second parameter) given its name or
ndex. If the third parameter is true return the short version of the type (ie.
ndex. Optional parameters are gen, to specify the generation, and form, to
Coleottero becomes Coleot if the Pokémon has two types), otherwise return the
ndexfull name. Optional parameters are gen, to specify the generation, and form, to
specify the form abbr.
 
--]]
local function getType(frame, typeNumber, short)
local pokes = mw.loadData('Modulo:Poké/data')
local p = wlib.trimAll(frame.args)
local type = multigen.getGenValue(
return txt.fu(
pokes[parseName(p)]["type" .. typeNumber],
multigen.getGenValue(
tonumber(p.gen)
pokes[parseName(p)]["type" .. typeNumber],
tonumber(p.gen)
)
)
if not short then
type = type == "coleot" and "coleottero" or type
)end
return txt.fu(type)
end
 
--]]
b.getType1 = function(frame)
return getType(frame, "1", false)
end
b.get_type_1 = b.getType1
--]]
b.getType2 = function(frame)
return getType(frame, "2", false)
end
b.get_type_2 = b.getType2
 
--[[
 
Same as getType1/2 but return the short version of the type, that is
"Coleottero" becomes "Coleot" if the Pokémon has two types.
 
Ex:
{{#invoke: PokémonData | getShortType2 | 752 }} --> Coleot
{{#invoke: PokémonData | getShortType1 | 0752 }} --> Acqua
{{#invoke: PokémonData | getShortType1 | Caterpie }} --> Coleottero
 
--]]
b.getShortType1 = function(frame)
return getType(frame, "1", true)
end
b.getShortType2 = function(frame)
return getType(frame, "2", true)
end
 
--[[
79 547

contributi