diff --git a/init.lua b/init.lua index 8d8a202..8194b82 100644 --- a/init.lua +++ b/init.lua @@ -70,11 +70,12 @@ function off_def.on_receive_fields(pos, formname, fields, sender) end end +--WARNING: the mesecon_onlinedetector group should NEVER assigned to another node, or you should expect the game to crash if has_mcl_core then - --off_def.groups = {cracky = 2, mesecon_detector_off = 1, mesecon = 2} - off_def.groups = {handy = 1, mesecon_detector_off = 1, mesecon = 2} + --off_def.groups = {cracky = 2, mesecon_onlinedetector = 1, mesecon_detector_off = 1, mesecon = 2} + off_def.groups = {handy = 1, mesecon_onlinedetector = 1, mesecon_detector_off = 1, mesecon = 2} else - off_def.groups = {cracky = 2, mesecon_detector_off = 1, mesecon = 2} + off_def.groups = {cracky = 2, mesecon_onlinedetector = 1, mesecon_detector_off = 1, mesecon = 2} end minetest.register_node("mesecons_onlinedetector:online_detector_off", off_def) @@ -131,6 +132,20 @@ minetest.register_abm({ end, }) +minetest.register_lbm({ + label = "Update onlinedetector state", + name = "mesecons_onlinedetector:online_detector", + nodenames = {"group:mesecon_onlinedetector"}, + run_at_every_load = true, + action = function(pos, node) + if node.name == "mesecons_onlinedetector:online_detector_off" then + update_detector_off(pos, minetest.get_meta(pos):get_string("name")) + else + update_detector_on(pos, minetest.get_meta(pos):get_string("name")) + end + end, +}) + if minetest.get_modpath("default") then minetest.register_craft({ output = "mesecons_onlinedetector:online_detector_off",