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

мНет описания правки
мНет описания правки
Строка 1: Строка 1:
local p = {}
local p = {}
local spriteData = mw.loadData("Модуль:IanComradeBot/prototypes/entity sprite.json/data")


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 param = frame.args[1]
     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 param == "repeat" then
     if action == "repeat" then
         return generateRepeatTemplate(spriteData)
         return generateRepeatTemplate(spriteData)
     elseif param == "image" or param == "path" then
     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, param)
             local template = generateTemplate(entry, action)
             if template then
             if template then
                 table.insert(result, template)
                 table.insert(result, template)