Модуль:Entity Sprite/all: различия между версиями
Pok (обсуждение | вклад) Нет описания правки |
Pok (обсуждение | вклад) Нет описания правки |
||
| Строка 2: | Строка 2: | ||
local JsonPaths = require('Module:JsonPaths') | local JsonPaths = require('Module:JsonPaths') | ||
local prefix = JsonPaths.prefixFile() | local prefix = JsonPaths.prefixFile() | ||
local function normalizeSpritePath(path) | local function normalizeSpritePath(path) | ||
| Строка 183: | Строка 153: | ||
return nil | return nil | ||
end | |||
local function shouldIncludeEntry(entry, whitelistSet, blacklistSet) | |||
local parents = getParents(entry) | |||
if whitelistSet and not hasAnyParent(parents, whitelistSet) then | |||
return false | |||
end | |||
if blacklistSet and hasAnyParent(parents, blacklistSet) then | |||
return false | |||
end | |||
return true | |||
end | |||
local function filterSpriteData(spriteData, prototypeData, whitelistSet, blacklistSet, project) | |||
local result = {} | |||
for id, entry in pairs(spriteData) do | |||
local protoEntry = prototypeData and prototypeData[id] or entry | |||
if shouldIncludeEntry(protoEntry, whitelistSet, blacklistSet) then | |||
if project == "" or JsonPaths.has(id, project) then | |||
result[id] = entry | |||
end | |||
end | |||
end | |||
return result | |||
end | end | ||