mirror of
https://github.com/cave-story-randomizer/cave-story-randomizer
synced 2024-11-22 06:43:03 +00:00
Added ability to generate plaintext TSCs.
This commit is contained in:
parent
69404d765e
commit
18cee13ecc
|
@ -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()
|
||||
|
||||
|
|
|
@ -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')
|
||||
|
|
Loading…
Reference in a new issue