mirror of
https://github.com/cave-story-randomizer/cave-story-randomizer
synced 2024-12-25 14:37:05 +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
|
||||
|
||||
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 = ""
|
||||
seedfile = tonumber(seedfile)
|
||||
if seedfile == nil or bytes < 10 then
|
||||
logWarning('Seed from file doesn' t exists or seems to be invalid, generate a new')
|
||||
if seed_from_file == nil or string.len(seed_from_file) < 10 then
|
||||
logWarning('Seed from file doesnt exists or seems to be invalid, generate a new')
|
||||
seed = tostring(os.time())
|
||||
else
|
||||
logNotice('Gathered the seed from file "seed.txt"')
|
||||
seed = seedfile
|
||||
seed = seed_from_file
|
||||
end
|
||||
math.randomseed(seed)
|
||||
logNotice(('Offering seed "%s" to RNGesus'):format(seed))
|
||||
logNotice(('Offering seed "%s" to RNGesus' ):format(seed))
|
||||
end
|
||||
|
||||
function C:_createTscFiles(dirStage)
|
||||
local tscFiles = {}
|
||||
for _, filename in ipairs(TSC_FILES) do
|
||||
local path = dirStage .. '/' .. filename .. '.tsc'
|
||||
local path = dirStage .. '/' .. filename .. ".tsc"
|
||||
tscFiles[filename] = TscFile(path)
|
||||
tscFiles[filename].mapName = filename
|
||||
end
|
||||
|
|
|
@ -22,7 +22,7 @@ function C:new(path)
|
|||
|
||||
-- Determine set of items which can be replaced later.
|
||||
--[[
|
||||
self._unreplaced = {}
|
||||
self._unreplaced = {}
|
||||
self._mapName = path:match("^.+/(.+)$")
|
||||
for k, v in pairs(ITEM_DATA) do repeat
|
||||
if (v.map .. '.tsc') ~= self._mapName then
|
||||
|
@ -32,7 +32,7 @@ function C:new(path)
|
|||
table.insert(self._unreplaced, item)
|
||||
until true end
|
||||
self._unreplaced = _.shuffle(self._unreplaced)
|
||||
]]
|
||||
]]
|
||||
end
|
||||
|
||||
function C:hasUnreplacedItems()
|
||||
|
|
Loading…
Reference in a new issue