Модуль:Entity Sprite/all: различия между версиями

Нет описания правки
Нет описания правки
Строка 214: Строка 214:
end
end


local function generateRepeatTemplate(data, project)
local function getRepeatSpriteLink(entry, baseUrl)
local states = getSpriteStates(entry)
if not states or #states == 0 then
local spritePath = getSpritePath(entry)
if spritePath then
return "[" .. baseUrl .. spritePath .. " " .. spritePath .. "]"
end
return nil
end
 
local links = {}
for _, item in ipairs(states) do
if item.sprite and item.state then
local url = baseUrl .. item.sprite .. "/" .. item.state .. ".png"
table.insert(links, "[" .. url .. " " .. item.state .. "]")
end
end
 
return table.concat(links, ", ")
end
 
local function generateRepeatTemplate(data, project, baseUrl)
local spriteGroups = {}
local spriteGroups = {}


Строка 232: Строка 253:
for _, obj in ipairs(group) do
for _, obj in ipairs(group) do
local id = obj.id
local id = obj.id
local entry = obj.entry
local prefix = getPrefix(id, project)
local prefix = getPrefix(id, project)
local spriteLinks = getRepeatSpriteLink(entry, baseUrl)


table.insert(idLinks, "[[:Файл:" .. prefix .. id .. ".png]]")
if spriteLinks then
table.insert(idLinks, spriteLinks)
else
table.insert(idLinks, "[[:Файл:" .. prefix .. id .. ".png]]")
end
end
end