Модуль:Entity Lookup: различия между версиями
Pok (обсуждение | вклад) Нет описания правки |
Pok (обсуждение | вклад) Нет описания правки |
||
| Строка 10: | Строка 10: | ||
p.entities = safeLoad("entity prototypes.json") | p.entities = safeLoad("entity prototypes.json") | ||
p.name_overrides = safeLoad("entity name overrides.json") | p.name_overrides = safeLoad("entity name overrides.json") | ||
local function lower(value) | |||
return mw.ustring.lower(value) | |||
end | |||
local function buildName(entity, useSuffix) | local function buildName(entity, useSuffix) | ||
local name = entity.name or "" | local name = entity.name or "" | ||
local label = | local label = lower(entity.label or "") | ||
local suffix = "" | local suffix = lower(entity.suffix or "") | ||
if useSuffix | if useSuffix and suffix ~= "" then | ||
local parts = {} | |||
for part in tostring(suffix):gmatch("[^,;]+") do | |||
part = part | |||
if part ~= "" then | |||
parts[#parts + 1] = part | |||
end | end | ||
end | end | ||
suffix = table.concat(parts, ", ") | |||
end | end | ||
| Строка 57: | Строка 56: | ||
local override = p.name_overrides[id] | local override = p.name_overrides[id] | ||
if override then | if override then | ||
return override | return lower(override) | ||
end | end | ||
| Строка 65: | Строка 64: | ||
end | end | ||
local useSuffix = frame.args and frame.args.suffix and | local useSuffix = frame.args and frame.args.suffix and frame.args.suffix ~= "" | ||
return buildName(entity, useSuffix) | return buildName(entity, useSuffix) | ||
end | end | ||