aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBeha <shacknetisp@mail.com>2018-09-25 11:24:03 -0400
committerBeha <shacknetisp@mail.com>2018-09-25 11:24:03 -0400
commitfd374c37d23df92838cd25f0a2b2a5cc56da485c (patch)
treebda0ae545d00a9de8ad56e9e2137bb5d793883cd
parent4f389f287c3d7c5ea286b0b8a2984bc4be9537f0 (diff)
downloadelevator-fd374c37d23df92838cd25f0a2b2a5cc56da485c.zip
elevator-fd374c37d23df92838cd25f0a2b2a5cc56da485c.tar.gz
elevator-fd374c37d23df92838cd25f0a2b2a5cc56da485c.tar.bz2
Fix saving, add mod.conf. Closes #7.
-rw-r--r--init.lua13
-rw-r--r--mod.conf3
2 files changed, 14 insertions, 2 deletions
diff --git a/init.lua b/init.lua
index 0c039d2..450d767 100644
--- a/init.lua
+++ b/init.lua
@@ -18,9 +18,15 @@ local elevator = {
motors = {},
}
+local str = minetest.get_mod_storage and minetest.get_mod_storage()
+
local elevator_file = minetest.get_worldpath() .. "/elevator"
local function load_elevator()
+ if str and str:contains("data") then
+ elevator = minetest.deserialize(str:get_string("data"))
+ return
+ end
local file = io.open(elevator_file)
if file then
elevator = minetest.deserialize(file:read("*all")) or {}
@@ -29,10 +35,13 @@ local function load_elevator()
end
local function save_elevator()
- local f = io.open(elevator_file .. ".tmp", "w")
+ if str then
+ str:set_string("data", minetest.serialize(elevator))
+ return
+ end
+ local f = io.open(elevator_file, "w")
f:write(minetest.serialize(elevator))
f:close()
- os.rename(elevator_file .. ".tmp", elevator_file)
end
load_elevator()
diff --git a/mod.conf b/mod.conf
new file mode 100644
index 0000000..b86b042
--- /dev/null
+++ b/mod.conf
@@ -0,0 +1,3 @@
+name = elevator
+depends = default
+optional_depends = technic, homedecor, chains, farming