From bfd3ec036055f658fc767bf61a64143e10d02549 Mon Sep 17 00:00:00 2001 From: Trashbox Bobylev Date: Sun, 24 Mar 2019 23:16:13 +0700 Subject: [PATCH] Added ability to read seed from seed.txt in randomizer's home file --- src/randomizer.lua | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/randomizer.lua b/src/randomizer.lua index ca9352a..59d2074 100644 --- a/src/randomizer.lua +++ b/src/randomizer.lua @@ -29,6 +29,7 @@ function C:randomize(path) if not success then return "Could not find \"data\" subfolder.\n\nMaybe try dropping your Cave Story \"data\" folder in directly?" end + self:_seedRngesus() local tscFiles = self:_createTscFiles(dirStage) -- self:_writePlaintext(tscFiles) @@ -71,8 +72,16 @@ function C:_mountDirectory(path) end function C:_seedRngesus() - local seed = tostring(os.time()) - math.randomseed(seed) + 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) + else + logNotice('Gathered seed from file') + seed = seedfile + end logNotice(('Offering seed "%s" to RNGesus'):format(seed)) end