mirror of
https://github.com/cave-story-randomizer/cave-story-randomizer
synced 2024-11-22 14:53:00 +00:00
Gathering seed from file rewrited to use native Lua IO
This commit is contained in:
parent
d88a81fc98
commit
2687db83ab
|
@ -72,24 +72,23 @@ function C:_mountDirectory(path)
|
||||||
end
|
end
|
||||||
|
|
||||||
function C:_seedRngesus()
|
function C:_seedRngesus()
|
||||||
local seedfile, bytes= lf.read(lf.getSourceBaseDirectory() + "seed.txt",10);
|
local seed_from_file = io.open(lf.getSourceBaseDirectory() + "seed.txt"):read('*10')
|
||||||
local seed = ""
|
local seed = ""
|
||||||
seedfile = tonumber(seedfile)
|
if seed_from_file == nil or string.len(seed_from_file) < 10 then
|
||||||
if seedfile == nil or bytes < 10 then
|
logWarning('Seed from file doesnt exists or seems to be invalid, generate a new')
|
||||||
logWarning('Seed from file doesn' t 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('Gathered the seed from file "seed.txt"')
|
||||||
seed = seedfile
|
seed = seed_from_file
|
||||||
end
|
end
|
||||||
math.randomseed(seed)
|
math.randomseed(seed)
|
||||||
logNotice(('Offering seed "%s" to RNGesus'):format(seed))
|
logNotice(('Offering seed "%s" to RNGesus' ):format(seed))
|
||||||
end
|
end
|
||||||
|
|
||||||
function C:_createTscFiles(dirStage)
|
function C:_createTscFiles(dirStage)
|
||||||
local tscFiles = {}
|
local tscFiles = {}
|
||||||
for _, filename in ipairs(TSC_FILES) do
|
for _, filename in ipairs(TSC_FILES) do
|
||||||
local path = dirStage .. '/' .. filename .. '.tsc'
|
local path = dirStage .. '/' .. filename .. ".tsc"
|
||||||
tscFiles[filename] = TscFile(path)
|
tscFiles[filename] = TscFile(path)
|
||||||
tscFiles[filename].mapName = filename
|
tscFiles[filename].mapName = filename
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue