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

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


local function getFirstSpriteAndState(entry)
local function getRepeatSpriteUrl(entry, baseUrl)
local spritePath = getSpritePath(entry)
local spritePath = getSpritePath(entry)
local states = getSpriteStates(entry)
local states = getSpriteStates(entry)


if not spritePath then
if not spritePath then
return nil, nil
return nil
end
end


if states and #states > 0 and states[1].state then
if states and #states > 0 and states[1].state then
return spritePath, states[1].state
return baseUrl .. spritePath .. "/" .. states[1].state .. ".png"
end
end


return spritePath, entry and entry.state or nil
if entry and entry.state then
return baseUrl .. spritePath .. "/" .. tostring(entry.state) .. ".png"
end
 
return baseUrl .. spritePath
end
end


local function generateRepeatTemplate(data, project)
local function generateRepeatTemplate(data, project, baseUrl)
local spriteGroups = {}
local spriteGroups = {}


Строка 214: Строка 218:
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 spriteUrl = getRepeatSpriteUrl(entry, baseUrl)


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


Строка 232: Строка 240:
table.insert(result, mw.getCurrentFrame():preprocess(
table.insert(result, mw.getCurrentFrame():preprocess(
"{{Entity Sprite/Repeat|спрайты=" .. table.concat(idLinks, " ") ..
"{{Entity Sprite/Repeat|спрайты=" .. table.concat(idLinks, " ") ..
"|спрайт=" .. spriteValue ..
"|перенаправление=" .. prefix .. firstId ..
"|перенаправление=" .. prefix .. firstId ..
"|id=" .. firstId ..
"|id=" .. firstId ..
"|спрайт=" .. spriteValue ..
"}}"
"}}"
))
))