Distributed version works now, hopefully!

This commit is contained in:
shru 2018-12-14 21:49:12 -05:00
parent c1f466af8e
commit 5fffdcc659
3 changed files with 19 additions and 10 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
data/*

View File

@ -30,10 +30,14 @@ do
end
-- function love.load()
-- -- readPXM('Pole.pxm')
-- -- readTSC('Pole.tsc', 'Testing.tsc')
-- -- writeTSC('Testing.tsc')
-- -- readTSC('TestingEncoded.tsc', 'TestingDecoded.tsc')
-- local sourcePath = lf.getSourceBaseDirectory()
-- local info = lf.getInfo(sourcePath .. '/data')
-- local items = lf.getDirectoryItems(sourcePath)
-- print(Serpent.block(items))
-- print(Serpent.block(info))
-- if info == nil then
-- print()
-- end
-- end
function love.directorydropped(path)
@ -66,9 +70,15 @@ function love.directorydropped(path)
end
end
local sourcePath = lf.getSourceBaseDirectory()
-- Create /data/Stage if it doesn't already exist.
local command = ('mkdir "%s"'):format(sourcePath .. '/data/Stage')
os.execute(command) -- HERE BE DRAGONS!!!
-- Write modified files.
for filename, tscFile in pairs(tscFiles) do
local path = '/data/Stage/' .. filename
local path = sourcePath .. '/data/Stage/' .. filename
tscFile:writeTo(path)
end

View File

@ -63,13 +63,11 @@ function C:replaceItem(replacement)
end
function C:writeTo(path)
local encoded = self:_codec(self._text, 'encode')
logInfo('writing TSC to: ' .. path)
local filepath = lf.getSourceBaseDirectory() .. path
logInfo('writing TSC to: ' .. filepath)
local file, err = io.open(filepath, MODE_WRITE_ERASE_EXISTING)
local file, err = io.open(path, MODE_WRITE_ERASE_EXISTING)
assert(err == nil, err)
local encoded = self:_codec(self._text, 'encode')
file:write(encoded)
file:flush()
file:close()