Skip to content

Commit

Permalink
various fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
BuckarooBanzay committed Aug 14, 2024
1 parent 88ff77d commit 3ab6040
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
7 changes: 5 additions & 2 deletions data.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,12 @@ function mapsync.save_data(key, value)
return
end

local f = assert(global_env.io.open(data_backend_def.path .. "/" .. key .. ".lua", "w"))
f:write(minetest.serialize(value))
local filename = data_backend_def.path .. "/" .. key .. ".lua"
local f = assert(global_env.io.open(filename, "w"))
local data = minetest.serialize(value)
f:write(data)
f:close()
minetest.log("action", "[mapsync] wrote " .. #data .. " bytes of data to '" .. filename .. "'")
end

-- load simple key-value data
Expand Down
14 changes: 9 additions & 5 deletions integrations/elevator.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@ function elevator.save_elevator()
old_elevator_save_elevator()
end

-- load from backend if available
local data = mapsync.load_data("elevator")
if data and data.motors then
elevator.motors = data.motors
end
local function load()
-- load from backend if available
local data = mapsync.load_data("elevator")
if data and data.motors then
elevator.motors = data.motors
end
end

minetest.register_on_mods_loaded(load)
2 changes: 1 addition & 1 deletion integrations/hyperloop.lua
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ local function load()
end

-- load on startup
load()
minetest.register_on_mods_loaded(load)

0 comments on commit 3ab6040

Please sign in to comment.