All situations is tested, custom seed functional is complete

This commit is contained in:
Trashbox Bobylev 2019-03-25 23:15:41 +07:00
parent 35da7227bc
commit 3340f38737

View file

@ -72,14 +72,20 @@ function C:_mountDirectory(path)
end end
function C:_seedRngesus() function C:_seedRngesus()
local seed_from_file = io.open(lf.getSourceBaseDirectory() .. "seed.txt"):read('*10') local seed = io.open(lf.getSourceBaseDirectory() .. "/seed.txt")
local seed = "" if seed == nil then
if seed_from_file == nil or string.len(seed_from_file) < 10 then logNotice('Seed from file doesnt exists, generate a new')
logWarning('Seed from file doesnt exists or seems to be invalid, generate a new')
seed = tostring(os.time()) seed = tostring(os.time())
else else
logNotice('Gathered the seed from file "seed.txt"') logNotice('Gathering the seed from file "seed.txt"')
seed = seed_from_file seed = seed:read('*n')
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 end
math.randomseed(seed) math.randomseed(seed)
logNotice(('Offering seed "%s" to RNGesus' ):format(seed)) logNotice(('Offering seed "%s" to RNGesus' ):format(seed))