Модуль:Песочница/Pok: различия между версиями

Нет описания правки
Нет описания правки
Строка 1: Строка 1:
local p = {}
local p = {}
local JsonPaths = require('Module:JsonPaths')
local JsonPaths = require('Module:JsonPaths')
local function deepEqual(t1, t2)
    if t1 == t2 then return true end
    if type(t1) ~= "table" or type(t2) ~= "table" then return false end
    for k, v in pairs(t1) do
        if not deepEqual(v, t2[k]) then
            return false
        end
    end
    for k, v in pairs(t2) do
        if not deepEqual(v, t1[k]) then
            return false
        end
    end
    return true
end


local function getSpritePath(entry)
local function getSpritePath(entry)
Строка 44: Строка 25:


     return "https://github.com/space-syndicate/space-station-14/blob/master/Resources/Textures/"
     return "https://github.com/space-syndicate/space-station-14/blob/master/Resources/Textures/"
end
local function getPrefix(id, project)
    if project ~= "" and JsonPaths.has(id, project) then
        return project .. ":"
    end
    return ""
end
end


Строка 55: Строка 43:
             local g = group[1]
             local g = group[1]


             if entry.sprite == g.sprite and entry.state == g.state then
             if entry.sprite == g.entry.sprite and entry.state == g.entry.state then
                 table.insert(group, { id = id, entry = entry })
                 table.insert(group, { id = id, entry = entry })
                 found = true
                 found = true
Строка 77: Строка 65:
             for _, obj in pairs(group) do
             for _, obj in pairs(group) do
                 local id = obj.id
                 local id = obj.id
                 local prefix = (project ~= "" and JsonPaths.has(id)) and (project .. ":") or ""
                 local prefix = getPrefix(id, project)
 
                 table.insert(idLinks, "[[:Файл:" .. prefix .. id .. ".png]]")
                 table.insert(idLinks, "[[:Файл:" .. prefix .. id .. ".png]]")
             end
             end
Строка 99: Строка 88:
     end
     end


     local prefix = (project ~= "" and JsonPaths.has(id)) and (project .. ":") or ""
     local prefix = getPrefix(id, project)


     local states = getSpriteStates(entry)
     local states = getSpriteStates(entry)