mirror of
https://github.com/cave-story-randomizer/cave-story-randomizer
synced 2024-11-22 14:53:00 +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
|
end
|
||||||
self:_seedRngesus()
|
self:_seedRngesus()
|
||||||
local tscFiles = self:_createTscFiles(dirStage)
|
local tscFiles = self:_createTscFiles(dirStage)
|
||||||
|
-- self:_writePlaintext(tscFiles)
|
||||||
local canNotBreakBlocks = self:_shuffleItems(tscFiles)
|
local canNotBreakBlocks = self:_shuffleItems(tscFiles)
|
||||||
self:_writeModifiedData(tscFiles)
|
self:_writeModifiedData(tscFiles)
|
||||||
|
-- self:_writePlaintext(tscFiles)
|
||||||
if canNotBreakBlocks then
|
if canNotBreakBlocks then
|
||||||
self:_copyModifiedFirstCave()
|
self:_copyModifiedFirstCave()
|
||||||
end
|
end
|
||||||
|
@ -82,6 +84,20 @@ function C:_createTscFiles(dirStage)
|
||||||
return tscFiles
|
return tscFiles
|
||||||
end
|
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)
|
function C:_shuffleItems(tscFiles)
|
||||||
local itemDeck = ItemDeck()
|
local itemDeck = ItemDeck()
|
||||||
|
|
||||||
|
|
|
@ -127,6 +127,11 @@ function C:_stringReplace(text, needle, replacement)
|
||||||
return a .. replacement .. b, true
|
return a .. replacement .. b, true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function C:writePlaintextTo(path)
|
||||||
|
logInfo('writing Plaintext TSC to: ' .. path)
|
||||||
|
U.writeFile(path, self._text)
|
||||||
|
end
|
||||||
|
|
||||||
function C:writeTo(path)
|
function C:writeTo(path)
|
||||||
logInfo('writing TSC to: ' .. path)
|
logInfo('writing TSC to: ' .. path)
|
||||||
local encoded = self:_codec(self._text, 'encode')
|
local encoded = self:_codec(self._text, 'encode')
|
||||||
|
|
Loading…
Reference in a new issue