Модуль:Entity Sprite/all: различия между версиями
Pok (обсуждение | вклад) мНет описания правки |
Pok (обсуждение | вклад) мНет описания правки |
||
| Строка 1: | Строка 1: | ||
local p = {} | local p = {} | ||
local function loadData(filePath) | local function loadData(filePath) | ||
local page = mw.title.new(filePath) | local page = mw.title.new(filePath) | ||
| Строка 8: | Строка 7: | ||
end | end | ||
local function deepEqual(t1, t2) | local function deepEqual(t1, t2) | ||
if t1 == t2 then return true end | if t1 == t2 then return true end | ||
| Строка 47: | Строка 45: | ||
end | end | ||
local function getInsensitiveKey(t, target) | local function getInsensitiveKey(t, target) | ||
target = target:lower() | target = target:lower() | ||
| Строка 58: | Строка 55: | ||
end | end | ||
local function getSpritePath(entry) | local function getSpritePath(entry) | ||
local spriteField = getInsensitiveKey(entry, "Sprite") | local spriteField = getInsensitiveKey(entry, "Sprite") | ||
| Строка 77: | Строка 73: | ||
end | end | ||
local function getSpriteState(entry) | |||
local spriteBlock = getInsensitiveKey(entry, "Sprite") | |||
if spriteBlock then | |||
if spriteBlock.state then | |||
return spriteBlock.state | |||
elseif spriteBlock.layers then | |||
for _, layer in pairs(spriteBlock.layers) do | |||
if layer.state then | |||
return layer.state | |||
end | |||
end | |||
end | |||
end | |||
local iconBlock = getInsensitiveKey(entry, "Icon") | |||
if iconBlock and iconBlock.state then | |||
return iconBlock.state | |||
end | |||
return nil | |||
end | |||
local function generateRepeatTemplate(data) | local function generateRepeatTemplate(data) | ||
local spriteGroups = {} | local spriteGroups = {} | ||
| Строка 112: | Строка 129: | ||
end | end | ||
local function generateTemplate(entry, param, data) | local function generateTemplate(entry, param, data) | ||
local spritePath = getSpritePath(entry) | local spritePath = getSpritePath(entry) | ||
| Строка 121: | Строка 137: | ||
local spriteField = getInsensitiveKey(entry, "Sprite") | local spriteField = getInsensitiveKey(entry, "Sprite") | ||
local state = getSpriteState(entry) | |||
local state = | |||
if param == "image" then | if param == "image" then | ||