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

Нет описания правки
Нет описания правки
Строка 32: Строка 32:
     end
     end
     return ""
     return ""
end
local function fileExists(name)
    local title = mw.title.new(name, "File")
    return title and title.exists
end
end


Строка 113: Строка 118:
function p.main(frame)
function p.main(frame)
     local action = frame.args[1]
     local action = frame.args[1]
 
    local checkFile = frame.args.checkFile == "1"
   
     local project = JsonPaths.project()
     local project = JsonPaths.project()
     local baseUrl = getTextureBaseUrl(project)
     local baseUrl = getTextureBaseUrl(project)
     local dataPage = JsonPaths.get("prototype/sprite.json")
     local dataPage = JsonPaths.get("prototype/sprite.json")
     local spriteData = mw.loadData(dataPage)
     local spriteData = mw.loadData(dataPage)
Строка 131: Строка 136:


         for id, entry in pairs(spriteData) do
         for id, entry in pairs(spriteData) do
             local t = generateTemplate(id, entry, baseUrl, project)
             local prefix = getPrefix(id, project)
            if t then
 
                table.insert(result, t)
local skip = false
            end
if checkFile then
    local fileName = prefix .. id .. ".png"
    if fileExists(fileName) then
        skip = true
    end
end
if not skip then
    local t = generateTemplate(id, entry, baseUrl, project)
    if t then
        table.insert(result, t)
    end
end
         end
         end