mirror of
https://github.com/cave-story-randomizer/cave-story-randomizer
synced 2024-11-12 18:02:52 +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
|
||||||
|
|
|
@ -22,7 +22,7 @@ function C:new(path)
|
||||||
|
|
||||||
-- Determine set of items which can be replaced later.
|
-- Determine set of items which can be replaced later.
|
||||||
--[[
|
--[[
|
||||||
self._unreplaced = {}
|
self._unreplaced = {}
|
||||||
self._mapName = path:match("^.+/(.+)$")
|
self._mapName = path:match("^.+/(.+)$")
|
||||||
for k, v in pairs(ITEM_DATA) do repeat
|
for k, v in pairs(ITEM_DATA) do repeat
|
||||||
if (v.map .. '.tsc') ~= self._mapName then
|
if (v.map .. '.tsc') ~= self._mapName then
|
||||||
|
@ -32,7 +32,7 @@ function C:new(path)
|
||||||
table.insert(self._unreplaced, item)
|
table.insert(self._unreplaced, item)
|
||||||
until true end
|
until true end
|
||||||
self._unreplaced = _.shuffle(self._unreplaced)
|
self._unreplaced = _.shuffle(self._unreplaced)
|
||||||
]]
|
]]
|
||||||
end
|
end
|
||||||
|
|
||||||
function C:hasUnreplacedItems()
|
function C:hasUnreplacedItems()
|
||||||
|
|
Loading…
Reference in a new issue