forked from minetest-mods/MoreMesecons
Use mod storage for jammer, too
This commit is contained in:
parent
75abcb3077
commit
41c9b342c0
@ -3,16 +3,25 @@ local get = vector.get_data_from_pos
|
|||||||
local set = vector.set_data_to_pos
|
local set = vector.set_data_to_pos
|
||||||
local remove = vector.remove_data_from_pos
|
local remove = vector.remove_data_from_pos
|
||||||
|
|
||||||
local jammers = {}
|
local jammers
|
||||||
|
local storage = minetest.get_mod_storage()
|
||||||
|
jammers = minetest.deserialize(storage:get_string("jammers")) or {}
|
||||||
|
|
||||||
|
local function update_mod_storage()
|
||||||
|
storage:set_string("jammers", minetest.serialize(jammers))
|
||||||
|
end
|
||||||
|
|
||||||
local function add_jammer(pos)
|
local function add_jammer(pos)
|
||||||
if get(jammers, pos.z,pos.y,pos.x) then
|
if get(jammers, pos.z,pos.y,pos.x) then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
set(jammers, pos.z,pos.y,pos.x, true)
|
set(jammers, pos.z,pos.y,pos.x, true)
|
||||||
|
update_mod_storage()
|
||||||
end
|
end
|
||||||
|
|
||||||
local function remove_jammer(pos)
|
local function remove_jammer(pos)
|
||||||
remove(jammers, pos.z,pos.y,pos.x)
|
remove(jammers, pos.z,pos.y,pos.x)
|
||||||
|
update_mod_storage()
|
||||||
end
|
end
|
||||||
|
|
||||||
local function is_jammed(pos)
|
local function is_jammed(pos)
|
||||||
@ -124,9 +133,11 @@ minetest.register_craft({
|
|||||||
{"", "moremesecons_wireless:jammer_off", ""}}
|
{"", "moremesecons_wireless:jammer_off", ""}}
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_lbm({
|
if moremesecons.setting("jammer", "enable_lbm", false) then
|
||||||
name = "moremesecons_jammer:add_jammer",
|
minetest.register_lbm({
|
||||||
nodenames = {"moremesecons_jammer:jammer_on"},
|
name = "moremesecons_jammer:add_jammer",
|
||||||
run_at_every_load = true,
|
nodenames = {"moremesecons_jammer:jammer_on"},
|
||||||
action = add_jammer
|
run_at_every_load = true,
|
||||||
})
|
action = add_jammer
|
||||||
|
})
|
||||||
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user