Make the mod working with current stable release

This commit is contained in:
upsilon 2017-05-02 18:11:24 +02:00
parent 8c267be40d
commit abe8368e32
No known key found for this signature in database
GPG Key ID: A80DAE1F266E1C3C
3 changed files with 50 additions and 14 deletions

@ -4,10 +4,20 @@ local set = vector.set_data_to_pos
local remove = vector.remove_data_from_pos
local jammers
local storage = minetest.get_mod_storage()
jammers = minetest.deserialize(storage:get_string("jammers")) or {}
local enable_lbm = moremesecons.setting("jammer", "enable_lbm", false)
local storage
if not minetest.get_mod_storage then
enable_lbm = true -- No mod storage (<= 0.4.15-stable): force registration of LBM
jammers = {}
else
storage = minetest.get_mod_storage()
jammers = minetest.deserialize(storage:get_string("jammers")) or {}
end
local function update_mod_storage()
if not storage then
return
end
storage:set_string("jammers", minetest.serialize(jammers))
end
@ -133,7 +143,7 @@ minetest.register_craft({
{"", "moremesecons_wireless:jammer_off", ""}}
})
if moremesecons.setting("jammer", "enable_lbm", false) then
if enable_lbm then
minetest.register_lbm({
name = "moremesecons_jammer:add_jammer",
nodenames = {"moremesecons_jammer:jammer_on"},

@ -1,12 +1,25 @@
local teleporters
local teleporters_rids
local storage = minetest.get_mod_storage()
teleporters = minetest.deserialize(storage:get_string("teleporters")) or {}
teleporters_rids = minetest.deserialize(storage:get_string("teleporters_rids")) or {}
jammers = minetest.deserialize(storage:get_string("jammers")) or {}
local enable_lbm = moremesecons.setting("teleporter", "enable_lbm", false)
local storage
if not minetest.get_mod_storage then
enable_lbm = true -- No mod storage (<= 0.4.15-stable): force registration of LBM
teleporters = {}
teleporters_rids = {}
jammers = {}
else
storage = minetest.get_mod_storage()
teleporters = minetest.deserialize(storage:get_string("teleporters")) or {}
teleporters_rids = minetest.deserialize(storage:get_string("teleporters_rids")) or {}
jammers = minetest.deserialize(storage:get_string("jammers")) or {}
end
local function update_mod_storage()
if not storage then
return
end
storage:set_string("teleporters", minetest.serialize(teleporters))
storage:set_string("teleporters_rids", minetest.serialize(teleporters_rids))
end
@ -100,7 +113,7 @@ minetest.register_node("moremesecons_teleporter:teleporter", {
end,
})
if moremesecons.setting("teleporter", "enable_lbm", false) then
if enable_lbm then
minetest.register_lbm({
name = "moremesecons_teleporter:add_teleporter",
nodenames = {"moremesecons_teleporter:teleporter"},

@ -2,12 +2,25 @@ local wireless
local wireless_meta -- This table contains wireless metadatas, it is a lot faster to access
local jammers
local storage = minetest.get_mod_storage()
wireless = minetest.deserialize(storage:get_string("wireless")) or {}
wireless_meta = minetest.deserialize(storage:get_string("wireless_meta")) or {owners = {}, channels = {}, ids = {}}
jammers = minetest.deserialize(storage:get_string("jammers")) or {}
local enable_lbm = moremesecons.setting("wireless", "enable_lbm", false)
local storage
if not minetest.get_mod_storage then
enable_lbm = true -- No mod storage (<= 0.4.15-stable): force registration of LBM
wireless = {}
wireless_meta = {owners = {}, channels = {}, ids = {}}
jammers = {}
else
storage = minetest.get_mod_storage()
wireless = minetest.deserialize(storage:get_string("wireless")) or {}
wireless_meta = minetest.deserialize(storage:get_string("wireless_meta")) or {owners = {}, channels = {}, ids = {}}
jammers = minetest.deserialize(storage:get_string("jammers")) or {}
end
local function update_mod_storage()
if not storage then
return
end
storage:set_string("wireless", minetest.serialize(wireless))
storage:set_string("wireless_meta", minetest.serialize(wireless_meta))
storage:set_string("jammers", minetest.serialize(jammers))
@ -364,7 +377,7 @@ minetest.register_craft({
}
})
if moremesecons.setting("wireless", "enable_lbm", false) then
if enable_lbm then
minetest.register_lbm({
name = "moremesecons_wireless:add_jammer",
nodenames = {"moremesecons_wireless:jammer_on"},
@ -382,7 +395,7 @@ end
-- Legacy
if storage:get_string("wireless_rids") and storage:get_string("wireless_rids") ~= "" then
if storage and storage:get_string("wireless_rids") and storage:get_string("wireless_rids") ~= "" then
-- Upgrade mod storage!
local wireless_rids = minetest.deserialize(storage:get_string("wireless_rids"))
local old_wireless = table.copy(wireless)