Модуль:Entity Sprite/all: различия между версиями
Pok (обсуждение | вклад) мНет описания правки |
Pok (обсуждение | вклад) мНет описания правки |
||
| Строка 67: | Строка 67: | ||
end | end | ||
local function | local function getSpriteStates(entry) | ||
local spriteBlock = getInsensitiveKey(entry, "Sprite") | |||
if spriteBlock and spriteBlock.layers then | |||
local states = {} | |||
for _, layer in ipairs(spriteBlock.layers) do | |||
if not(layer.visible == false) and layer.state then | |||
table.insert(states, layer.state) | |||
end | |||
end | |||
if #states > 0 then | |||
return states | |||
end | |||
end | |||
local iconBlock = getInsensitiveKey(entry, "Icon") | local iconBlock = getInsensitiveKey(entry, "Icon") | ||
if iconBlock and iconBlock.state then | if iconBlock and iconBlock.state then | ||
return iconBlock.state | return { iconBlock.state } | ||
end | end | ||
if spriteBlock and spriteBlock.state then | |||
return { spriteBlock.state } | |||
if spriteBlock | |||
end | end | ||
return nil | return nil | ||
end | end | ||
| Строка 130: | Строка 131: | ||
return nil | return nil | ||
end | end | ||
if param == "image" then | if param == "image" then | ||
local states = getSpriteStates(entry) | |||
local stateStr = "" | local stateStr = "" | ||
if | if states then | ||
local joined = table.concat(states, ", ") | |||
local base = "https://github.com/space-syndicate/space-station-14/blob/master/Resources/Textures/" .. spritePath .. "/" | |||
joined = mw.ustring.gsub(joined, "([%w_]+)", "[" .. base .. "%1.png %1]") | |||
stateStr = " " .. joined | |||
end | end | ||
return mw.getCurrentFrame():preprocess( | return mw.getCurrentFrame():preprocess( | ||
| Строка 172: | Строка 175: | ||
if action == "repeat" then | if action == "repeat" then | ||
return generateRepeatTemplate(spriteData) | return generateRepeatTemplate(spriteData) | ||
elseif action == "image | elseif action == "image" then | ||
local result = {} | local result = {} | ||
for _, entry in pairs(spriteData) do | for _, entry in pairs(spriteData) do | ||