Added ability to read seed from seed.txt in randomizer's home file

This commit is contained in:
Trashbox Bobylev 2019-03-24 23:16:13 +07:00
parent 5c7e994c45
commit bfd3ec0360

View file

@ -29,6 +29,7 @@ function C:randomize(path)
if not success then if not success then
return "Could not find \"data\" subfolder.\n\nMaybe try dropping your Cave Story \"data\" folder in directly?" return "Could not find \"data\" subfolder.\n\nMaybe try dropping your Cave Story \"data\" folder in directly?"
end end
self:_seedRngesus() self:_seedRngesus()
local tscFiles = self:_createTscFiles(dirStage) local tscFiles = self:_createTscFiles(dirStage)
-- self:_writePlaintext(tscFiles) -- self:_writePlaintext(tscFiles)
@ -71,8 +72,16 @@ function C:_mountDirectory(path)
end end
function C:_seedRngesus() function C:_seedRngesus()
local seed = tostring(os.time()) local seedfile, bytes= lf.read(lf.getSourceBaseDirectory() + "seed.txt", 9);
local seed = ""
if seedfile == nil then
logNotice('Okay, no seed file, generate new')
seed = tostring(os.time())
math.randomseed(seed) math.randomseed(seed)
else
logNotice('Gathered seed from file')
seed = seedfile
end
logNotice(('Offering seed "%s" to RNGesus'):format(seed)) logNotice(('Offering seed "%s" to RNGesus'):format(seed))
end end