aboutsummaryrefslogtreecommitdiff
path: root/advtrains_luaautomation
diff options
context:
space:
mode:
authororwell96 <orwell@bleipb.de>2020-12-21 20:04:33 +0100
committerorwell96 <orwell@bleipb.de>2021-01-12 13:27:00 +0100
commite42fbf9dcc2697ebda1a8fdd9cbedecbee92a6bb (patch)
tree97bf023b3fbf462b5ac587fb4d724b23a0e893f8 /advtrains_luaautomation
parentd0bd4ac30e8f14d40df01a91e346e7c2c589e0a9 (diff)
downloadadvtrains-e42fbf9dcc2697ebda1a8fdd9cbedecbee92a6bb.tar.gz
advtrains-e42fbf9dcc2697ebda1a8fdd9cbedecbee92a6bb.tar.bz2
advtrains-e42fbf9dcc2697ebda1a8fdd9cbedecbee92a6bb.zip
Make advtrains use serialize_lib (save version 4)
Old save format will be gracefully migrated
Diffstat (limited to 'advtrains_luaautomation')
-rw-r--r--advtrains_luaautomation/init.lua32
1 files changed, 18 insertions, 14 deletions
diff --git a/advtrains_luaautomation/init.lua b/advtrains_luaautomation/init.lua
index eca5633..a54fb25 100644
--- a/advtrains_luaautomation/init.lua
+++ b/advtrains_luaautomation/init.lua
@@ -39,7 +39,21 @@ dofile(mp.."/chatcmds.lua")
local filename=minetest.get_worldpath().."/advtrains_luaautomation"
-function atlatc.load()
+function atlatc.load(tbl)
+ if tbl.version==1 then
+ for envname, data in pairs(tbl.envs) do
+ atlatc.envs[envname]=atlatc.env_load(envname, data)
+ end
+ atlatc.active.load(tbl.active)
+ atlatc.interrupt.load(tbl.interrupt)
+ atlatc.pcnaming.load(tbl.pcnaming)
+ end
+ -- run init code of all environments
+ atlatc.run_initcode()
+end
+
+function atlatc.load_pre_v4()
+ minetest.log("action", "[atlatc] Loading pre-v4 save file")
local file, err = io.open(filename, "r")
if not file then
minetest.log("warning", " Failed to read advtrains_luaautomation save data from file "..filename..": "..(err or "Unknown Error"))
@@ -82,21 +96,10 @@ atlatc.save = function()
pcnaming = atlatc.pcnaming.save(),
}
- local datastr = minetest.serialize(save_tbl)
- if not datastr then
- minetest.log("error", " Failed to save advtrains_luaautomation save data to file "..filename..": Can't serialize!")
- return
- end
- local file, err = io.open(filename, "w")
- if err then
- minetest.log("error", " Failed to save advtrains_luaautomation save data to file "..filename..": "..(err or "Unknown Error"))
- return
- end
- file:write(datastr)
- file:close()
+ return save_tbl
end
-
+--[[
-- globalstep for step code
local timer, step_int=0, 2
@@ -107,3 +110,4 @@ function atlatc.mainloop_stepcode(dtime)
atlatc.run_stepcode()
end
end
+]]