mirror of
https://github.com/cave-story-randomizer/cave-story-randomizer
synced 2025-12-06 12:37:26 +00:00
All situations is tested, custom seed functional is complete
This commit is contained in:
parent
35da7227bc
commit
3340f38737
|
|
@ -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))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue