Модуль:Entity Sprite/all: различия между версиями
Pok (обсуждение | вклад) Нет описания правки |
Pok (обсуждение | вклад) Нет описания правки |
||
| Строка 1: | Строка 1: | ||
local p = {} | local p = {} | ||
local JsonPaths = require('Module:JsonPaths') | local JsonPaths = require('Module:JsonPaths') | ||
local function getSpritePath(entry) | local function getSpritePath(entry) | ||
| Строка 22: | Строка 20: | ||
elseif entry.state and entry.sprite then | elseif entry.state and entry.sprite then | ||
table.insert(result, { | table.insert(result, { | ||
state = tostring(entry.state or ""), | state = tostring(entry.state or ""), | ||
sprite = entry.sprite | sprite = entry.sprite | ||
}) | }) | ||
| Строка 35: | Строка 33: | ||
end | end | ||
return "" | return "" | ||
end | end | ||
| Строка 72: | Строка 59: | ||
local result = {} | local result = {} | ||
for _, group in pairs(spriteGroups) do | for _, group in pairs(spriteGroups) do | ||
| Строка 81: | Строка 67: | ||
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 | ||
table.insert(result, | table.insert(result, mw.getCurrentFrame():preprocess( | ||
"{{Entity Sprite/Repeat|" .. | "{{Entity Sprite/Repeat|" .. | ||
table.concat(idLinks, " ") .. | table.concat(idLinks, " ") .. | ||
| Строка 128: | Строка 115: | ||
local action = frame.args[1] | local action = frame.args[1] | ||
local json = frame.args.json or "sprite_entity.json" | local json = frame.args.json or "sprite_entity.json" | ||
local project = JsonPaths.project() | local project = JsonPaths.project() | ||
local baseUrl = JsonPaths.git() .. "/Resources/Textures/" | local baseUrl = JsonPaths.git() .. "/Resources/Textures/" | ||
| Строка 149: | Строка 132: | ||
for id, entry in pairs(spriteData) do | for id, entry in pairs(spriteData) do | ||
local t = generateTemplate(id, entry, baseUrl, project) | |||
if t then | |||
table.insert(result, t) | |||
end | end | ||
end | end | ||