adds support for alphanumeric seeds!

This commit is contained in:
duncathan 2019-09-11 21:04:14 -06:00
parent cec5cc5199
commit 366acf3de8

View file

@ -93,27 +93,17 @@ function C:_mountDirectory(path)
end
function C:_seedRngesus()
local seed = self.customseed or tostring(os.time())
--[[
local seed = io.open(lf.getSourceBaseDirectory() .. "/seed.txt")
local seed = self.customseed or os.time()
seed = tonumber(seed) or tonumber(seed, 36) -- convert alphanumeric strings to numbers
local seedstring = self.customseed or tostring(seed)
if seed == nil then
logNotice('Seed from file doesnt exists, generate a new')
seed = tostring(os.time())
else
logNotice('Gathering the seed from file "seed.txt"')
seed = seed:read('*n')
seed = os.time()
seedstring = ('%d ("%s" was invalid)'):format(seed, self.customseed)
end
if seed == nil then
logWarning('Seed from file is invalid, generate a new')
seed = tostring(os.time())
elseif string.len(seed) < 10 then
logWarning('Seed is too short, generate a new')
seed = tostring(os.time())
end
]]
love.math.setRandomSeed(seed)
logNotice(('Offering seed "%s" to RNGesus' ):format(seed))
return seed
logNotice(('Offering seed "%s" to RNGesus' ):format(seedstring))
return seedstring
end
function C:_createTscFiles(dirStage)
@ -238,7 +228,7 @@ function C:_getStatusMessage(seed)
local warnings, errors = countLogWarningsAndErrors()
local line1
if warnings == 0 and errors == 0 then
line1 = ("Randomized data successfully created!\nSeed: %d"):format(seed)
line1 = ("Randomized data successfully created!\nSeed: %s"):format(seed)
elseif warnings ~= 0 and errors == 0 then
line1 = ("Randomized data was created with %d warning(s)."):format(warnings)
else