Fix RWT initialization when creating new world (H#142)
parent
d123679b3c
commit
50a81dd1f3
|
@ -39,6 +39,7 @@ local rwt = {}
|
||||||
|
|
||||||
--Time Stamp (Seconds since start of world)
|
--Time Stamp (Seconds since start of world)
|
||||||
local e_time = 0
|
local e_time = 0
|
||||||
|
local e_has_loaded = false
|
||||||
|
|
||||||
local setting_rwt_real = minetest.settings:get("advtrains_lines_rwt_realtime")
|
local setting_rwt_real = minetest.settings:get("advtrains_lines_rwt_realtime")
|
||||||
if setting_rwt_real=="" then
|
if setting_rwt_real=="" then
|
||||||
|
@ -71,6 +72,8 @@ function rwt.set_time(t)
|
||||||
end
|
end
|
||||||
atlog("[lines][rwt] Initialized railway time: ",rwt.to_string(e_time))
|
atlog("[lines][rwt] Initialized railway time: ",rwt.to_string(e_time))
|
||||||
e_last_epoch = os.time()
|
e_last_epoch = os.time()
|
||||||
|
|
||||||
|
e_has_loaded = true
|
||||||
end
|
end
|
||||||
|
|
||||||
function rwt.get_time()
|
function rwt.get_time()
|
||||||
|
@ -78,6 +81,10 @@ function rwt.get_time()
|
||||||
end
|
end
|
||||||
|
|
||||||
function rwt.step(dt)
|
function rwt.step(dt)
|
||||||
|
if not e_has_loaded then
|
||||||
|
rwt.set_time(0)
|
||||||
|
end
|
||||||
|
|
||||||
if setting_rwt_real=="independent" then
|
if setting_rwt_real=="independent" then
|
||||||
-- Regular stepping with dtime
|
-- Regular stepping with dtime
|
||||||
e_time = e_time + dt
|
e_time = e_time + dt
|
||||||
|
|
|
@ -44,7 +44,8 @@ local filename=minetest.get_worldpath().."/advtrains_luaautomation"
|
||||||
function atlatc.load()
|
function atlatc.load()
|
||||||
local file, err = io.open(filename, "r")
|
local file, err = io.open(filename, "r")
|
||||||
if not file then
|
if not file then
|
||||||
minetest.log("error", " Failed to read advtrains_luaautomation save data from file "..filename..": "..(err or "Unknown Error"))
|
minetest.log("warning", " Failed to read advtrains_luaautomation save data from file "..filename..": "..(err or "Unknown Error"))
|
||||||
|
minetest.log("warning", " (this is normal when first enabling advtrains on this world)")
|
||||||
else
|
else
|
||||||
atprint("luaautomation reading file:",filename)
|
atprint("luaautomation reading file:",filename)
|
||||||
local tbl = minetest.deserialize(file:read("*a"))
|
local tbl = minetest.deserialize(file:read("*a"))
|
||||||
|
|
Loading…
Reference in New Issue