16 389
contributi
(Aggiunta funzione utile per il catch) |
(Aggiunte interfacce per ottenere i tipi da nome o ndex) |
||
local data
local abils
local forms
--[[
Returns the passed table if it's already been loaded, otherwise the module
named after the second parameter is loaded and returned. The module is loaded
with mw.loadData unless the third parameter is true
--]]
local loadData = function(tab, moduleName, useRequire)
if not tab then
local loadFunction = useRequire and require or mw.loadData
return
end
return tab
local getAbil = function(name, abilityNumber)
abils = loadData(abils, 'PokéAbil/data')
return abils[tonumber(name) or name]['ability' .. abilityNumber]
end
b.getNdex = function(frame)
data = loadData(data, 'Poké/data')
return string.tf(data[string.trim(frame.args[1] or ''):lower()].ndex)
end
b.getName = function(frame)
data = loadData(data, 'Poké/data')
return data[tonumber(string.trim(frame.args[1] or ''))].name
end
b.get_abil_d, b.get_abil_h, b.get_abil_n = b.getAbild, b.getAbild, b.getAbild
--[[
Returns a Pokémon's type (specified by the second parameter) given its name or
ndex. Transform 'coleot' into 'coleottero'
--]]
local getType = function(name, typeNumber)
data = loadData(data, 'Poké/data')
local pkmnType = data[tonumber(name) or name]['type' .. typeNumber]
pkmnType = pkmnType == 'coleot' and 'coleottero' or pkmnType
return pkmnType
end
-- Returns a Pokémon's first type given its name or ndex
b.getType1 = function(frame)
return getType(string.trim(frame.args[1] or ''):lower(), '1')
end
b.get_type_1 = b.getType1
-- Returns a Pokémon's second type given its name or ndex. If the Pokémon has
-- only one type, it returns the first type instead
b.getType2 = function(frame)
return getType(string.trim(frame.args[1] or ''):lower(), '2')
end
b.get_type_2 = b.getType2
--[[
b.getLink = function(frame)
local name, black = string.trim(frame.args[1]), string.trim(frame.args[2])
local link = forms.getLink(name, black)
|