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

Нет описания правки
Нет описания правки
Строка 2: Строка 2:
local JsonPaths = require('Module:JsonPaths')
local JsonPaths = require('Module:JsonPaths')
local prefix = JsonPaths.prefixFile()
local prefix = JsonPaths.prefixFile()
local function loadEntityIdsByProject(project)
local title = JsonPaths.getEntityDataTitle(project)
if not title or title == "" then
return nil
end
local ok, data = pcall(mw.loadData, title)
if not ok or type(data) ~= "table" then
return nil
end
return data
end
local function hasIdInEntityIds(entityIds, id)
if type(entityIds) ~= "table" then
return false
end
if entityIds[id] ~= nil then
return true
end
for _, value in ipairs(entityIds) do
if value == id then
return true
end
end
return false
end
local function filterByEntityIds(spriteData, entityIds)
if not entityIds then
return spriteData
end
local result = {}
for id, entry in pairs(spriteData) do
if hasIdInEntityIds(entityIds, id) then
result[id] = entry
end
end
return result
end


local function normalizeSpritePath(path)
local function normalizeSpritePath(path)
Строка 328: Строка 376:
local whitelistSet = buildSet(frame.args.whitelistParent)
local whitelistSet = buildSet(frame.args.whitelistParent)
local blacklistSet = buildSet(frame.args.blacklistParent)
local blacklistSet = buildSet(frame.args.blacklistParent)
 
local filteredData = filterSpriteData(spriteData, prototypeData, whitelistSet, blacklistSet)
local filteredData = filterSpriteData(spriteData, prototypeData, whitelistSet, blacklistSet)
local entityIds = loadEntityIdsByProject(project)
filteredData = filterByEntityIds(filteredData, entityIds)


if action == "repeat" then
if action == "repeat" then