Модуль:Entity Sprite/all: различия между версиями
Pok (обсуждение | вклад) мНет описания правки |
Pok (обсуждение | вклад) мНет описания правки |
||
| Строка 1: | Строка 1: | ||
local p = {} | local p = {} | ||
local function deepEqual(t1, t2) | local function deepEqual(t1, t2) | ||
| Строка 141: | Строка 139: | ||
end | end | ||
return mw.getCurrentFrame():preprocess( | return mw.getCurrentFrame():preprocess( | ||
"{{Entity Sprite/Image|" .. entry.id .. | "{{Entity Sprite/Image|" .. entry.id .. | ||
"|https://github.com/space-syndicate/space-station-14/blob/master/Resources/Textures/" .. | "|https://github.com/space-syndicate/space-station-14/blob/master/Resources/Textures/" .. | ||
spritePath .. stateStr .. "}}" | spritePath .. stateStr .. "}}" | ||
| Строка 151: | Строка 149: | ||
function p.main(frame) | function p.main(frame) | ||
local | local action = frame.args[1] | ||
local mode = frame.args[2] | |||
local dataPage | |||
if mode == "item" then | |||
dataPage = "Модуль:IanComradeBot/prototypes/entity sprite/item.json/data" | |||
elseif mode == "structure" then | |||
dataPage = "Модуль:IanComradeBot/prototypes/entity sprite/structure.json/data" | |||
elseif mode == "mob" then | |||
dataPage = "Модуль:IanComradeBot/prototypes/entity sprite/mob.json/data" | |||
elseif mode == "other" then | |||
dataPage = "Модуль:IanComradeBot/prototypes/entity sprite/other.json/data" | |||
else | |||
dataPage = "Модуль:IanComradeBot/prototypes/entity sprite.json/data" | |||
end | |||
local spriteData = mw.loadData(dataPage) | |||
if not spriteData or type(spriteData) ~= "table" then | if not spriteData or type(spriteData) ~= "table" then | ||
return "Ошибка: Невозможно загрузить данные из JSON." | return "Ошибка: Невозможно загрузить данные из JSON (" .. dataPage .. ")." | ||
end | end | ||
if | if action == "repeat" then | ||
return generateRepeatTemplate(spriteData) | return generateRepeatTemplate(spriteData) | ||
elseif | elseif action == "image" or action == "path" then | ||
local result = {} | local result = {} | ||
for _, entry in pairs(spriteData) do | for _, entry in pairs(spriteData) do | ||
local template = generateTemplate(entry, | local template = generateTemplate(entry, action) | ||
if template then | if template then | ||
table.insert(result, template) | table.insert(result, template) | ||