add spritedata()

This commit is contained in:
Christopher Monsanto 2020-05-26 16:08:12 -04:00
parent d9115bbfd2
commit dcd76c548c
3 changed files with 20 additions and 3 deletions

View File

@ -65,8 +65,8 @@ rule(
local input = {}
for file in iter(glob{"newsrc/models/*"}) do
local base = tup.base(file)
if base:find("-b") or base:find("-s") then
local sd = spritedata(tup.base(file))
if sd.data.b or sd.data.s then
goto continue
end
input += file
@ -130,7 +130,8 @@ end
local dexMissing = {}
for file in iter(glob{"newsrc/sprites/gen5/*.gif", "newsrc/models/*.gif"}) do
local base = tup.base(file)
if base:find("-b") or base:find("-s") or dexSet[base] then
local sd = spritedata(base)
if sd.data.b or sd.data.s or dexSet[base] then
goto continue
end
dexMissing += file

View File

@ -2,6 +2,7 @@
tup.include("util/strict.lua")
tup.include("util/lua-ext.lua")
tup.include("util/tup-ext.lua")
tup.include("util/sprites.lua")
ROOTDIR = tup.getcwd()

15
util/sprites.lua Normal file
View File

@ -0,0 +1,15 @@
function spritedata(basename)
local iter = basename:gmatch("[^-]+")
local result = {id = iter(), data = {}}
for flagtext in iter do
if flagtext:len() == 1 then
result.data[flagtext] = true
else
local flag = flagtext.sub(1, 1)
local text = flagtext.sub(2)
result.data[flag] = text
end
end
return result
end