2015-03-25 01:38:53 -04:00
|
|
|
require "libs/TSerial"
|
|
|
|
|
|
|
|
|
|
local targetFolder = "art"
|
|
|
|
|
|
|
|
|
|
function get(folder)
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function getAllAssets()
|
2015-03-25 03:58:37 -04:00
|
|
|
local properties = TSerial.unpack(love.filesystem.read("assets.prop") or "{}")
|
2015-03-25 01:38:53 -04:00
|
|
|
local objectnames = {}
|
|
|
|
|
local topFolder = "art"
|
|
|
|
|
local files = love.filesystem.getDirectoryItems(topFolder)
|
|
|
|
|
for _, folder in pairs(files) do
|
|
|
|
|
if string.sub(folder, 1, 1) ~= "_" then
|
|
|
|
|
-- we ignore directories which are prepended w/ an underscore
|
|
|
|
|
if not string.find(folder, "%.") then
|
|
|
|
|
objectnames[folder] = {}
|
2015-03-25 03:58:37 -04:00
|
|
|
-- love.filesystem.createDirectory("art/" .. folder)
|
2015-03-25 01:38:53 -04:00
|
|
|
-- this is a folder, probably
|
|
|
|
|
local newFiles = love.filesystem.getDirectoryItems(topFolder .. "/" .. folder)
|
|
|
|
|
for _, fileToAnalyze in pairs(newFiles) do
|
|
|
|
|
if fileToAnalyze:find("_r.png") or fileToAnalyze:find("_g.png") or fileToAnalyze:find("_b.png")then
|
|
|
|
|
local color
|
|
|
|
|
if fileToAnalyze:find("_r.png") then color = "red"
|
|
|
|
|
elseif fileToAnalyze:find("_g.png") then color = "green"
|
|
|
|
|
elseif fileToAnalyze:find("_b.png") then color = "blue" end
|
|
|
|
|
|
|
|
|
|
local name = fileToAnalyze:sub(1, fileToAnalyze:len() - 6)
|
2015-03-25 03:58:37 -04:00
|
|
|
|
|
|
|
|
if not properties[name] then
|
|
|
|
|
properties[name] = {}
|
|
|
|
|
properties[name].directory = folder
|
|
|
|
|
properties[name].sprites = {}
|
|
|
|
|
properties[name].class = "unmoveable"
|
|
|
|
|
properties[name].preload = false
|
2015-03-25 01:38:53 -04:00
|
|
|
end
|
2015-03-25 03:58:37 -04:00
|
|
|
properties[name].sprites[color] = topFolder .. "/" .. folder .. "/" .. fileToAnalyze
|
2015-03-25 01:38:53 -04:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2015-03-25 03:58:37 -04:00
|
|
|
str = TSerial.pack(properties, nil, true)
|
|
|
|
|
love.filesystem.write("assets.prop", str)
|
|
|
|
|
return properties
|
2015-03-25 01:38:53 -04:00
|
|
|
end
|