Modul:Firestone/Hero: Unterschied zwischen den Versionen
Die Seite wurde neu angelegt: „-- Modul:Firestone/Hero local Util = require('Modul:Firestone/Util') local I18n = require('Modul:Firestone/I18n') local H = {} local function loadTable(name) local ok, data = pcall(mw.loadData, name) if ok and type(data) == 'table' then return data end ok, data = pcall(require, name) if ok and type(data) == 'table' then return data end return {} end local function mergedHeroes() local all = {} local sources = { 'Modu…“ |
(kein Unterschied)
|
Version vom 5. November 2025, 11:50 Uhr
Die Dokumentation für dieses Modul kann unter Modul:Firestone/Hero/Doku erstellt werden
-- Modul:Firestone/Hero
local Util = require('Modul:Firestone/Util')
local I18n = require('Modul:Firestone/I18n')
local H = {}
local function loadTable(name)
local ok, data = pcall(mw.loadData, name)
if ok and type(data) == 'table' then return data end
ok, data = pcall(require, name)
if ok and type(data) == 'table' then return data end
return {}
end
local function mergedHeroes()
local all = {}
local sources = {
'Modul:Firestone/Data/Heroes',
'Modul:Firestone/Data/Guardians',
'Modul:Firestone/Data/WM',
}
for _,name in ipairs(sources) do
local t = loadTable(name)
for k,v in pairs(t) do
all[k] = v
end
end
return all
end
local HEROES = mergedHeroes()
local function autotr(key_name, value)
if type(value) ~= "string" then return value end
local k = Util.norm(key_name)
local i18 = I18n.get()
local m1 = (i18.i18n or {})[k]
local v = m1 and m1[Util.norm(value)]
return v or value
end
function H.handle(frame, args)
local name = args[2]
if Util.isEmpty(name) then return "" end
local real = Util.pickKey(HEROES, name)
if not real then return "" end
local hero = HEROES[real]
local path, i = {}, 3
while args[i] do
table.insert(path, args[i])
i = i + 1
end
local v = Util.deepGet(hero, path)
local last = path[#path] and tostring(path[#path]) or ""
v = autotr(last, v)
return tostring(v or "")
end
return H