Модуль:Entity Sprite/all: различия между версиями
Pok (обсуждение | вклад) Нет описания правки |
Pok (обсуждение | вклад) Нет описания правки |
||
| (не показаны 3 промежуточные версии этого же участника) | |||
| Строка 1: | Строка 1: | ||
local p = {} | local p = {} | ||
local JsonPaths = require('Module:JsonPaths') | local JsonPaths = require('Module:JsonPaths') | ||
local function normalizeSpritePath(path) | |||
if path == nil then | |||
return nil | |||
end | |||
path = mw.text.trim(tostring(path)) | |||
path = path:gsub("^/Textures/?", "") | |||
return path | |||
end | |||
local function buildEntryKey(entry) | local function buildEntryKey(entry) | ||
| Строка 28: | Строка 39: | ||
return table.concat(parts, ";") | return table.concat(parts, ";") | ||
end | end | ||
| Строка 185: | Строка 185: | ||
if #group > 1 then | if #group > 1 then | ||
local idLinks = {} | local idLinks = {} | ||
for _, obj in ipairs(group) do | for _, obj in ipairs(group) do | ||
local id = obj.id | local id = obj.id | ||
local prefix = getPrefix(id, project) | local prefix = getPrefix(id, project) | ||
table.insert(idLinks, "[[:Файл:" .. prefix .. id .. ".png]]") | table.insert(idLinks, "[[:Файл:" .. prefix .. id .. ".png]]") | ||
end | end | ||
local firstId = group[1].id | |||
local prefix = getPrefix(firstId, project) | |||
table.insert(result, mw.getCurrentFrame():preprocess( | table.insert(result, mw.getCurrentFrame():preprocess( | ||
"{{Entity Sprite/Repeat|" .. | "{{Entity Sprite/Repeat|спрайты=" .. table.concat(idLinks, " ") .. | ||
"|перенаправление=" .. prefix .. firstId .. | |||
"|" .. | "|id=" .. firstId .. | ||
"}}" | "}}" | ||
)) | )) | ||