Added ability to generate plaintext TSCs.

This commit is contained in:
shru 2018-12-20 00:07:01 -05:00
parent 69404d765e
commit 18cee13ecc
2 changed files with 21 additions and 0 deletions

View file

@ -28,8 +28,10 @@ function C:randomize(path)
end
self:_seedRngesus()
local tscFiles = self:_createTscFiles(dirStage)
-- self:_writePlaintext(tscFiles)
local canNotBreakBlocks = self:_shuffleItems(tscFiles)
self:_writeModifiedData(tscFiles)
-- self:_writePlaintext(tscFiles)
if canNotBreakBlocks then
self:_copyModifiedFirstCave()
end
@ -82,6 +84,20 @@ function C:_createTscFiles(dirStage)
return tscFiles
end
function C:_writePlaintext(tscFiles)
local sourcePath = lf.getSourceBaseDirectory()
-- Create /data/Plaintext if it doesn't already exist.
local command = ('mkdir "%s"'):format(sourcePath .. '/data/Plaintext')
os.execute(command) -- HERE BE DRAGONS!!!
-- Write modified files.
for filename, tscFile in pairs(tscFiles) do
local path = sourcePath .. '/data/Plaintext/' .. filename
tscFile:writePlaintextTo(path)
end
end
function C:_shuffleItems(tscFiles)
local itemDeck = ItemDeck()

View file

@ -127,6 +127,11 @@ function C:_stringReplace(text, needle, replacement)
return a .. replacement .. b, true
end
function C:writePlaintextTo(path)
logInfo('writing Plaintext TSC to: ' .. path)
U.writeFile(path, self._text)
end
function C:writeTo(path)
logInfo('writing TSC to: ' .. path)
local encoded = self:_codec(self._text, 'encode')