2017-02-02 07:40:51 -08:00
|
|
|
-- p_mesecon_iface.lua
|
|
|
|
-- Mesecons interface by overriding the switch
|
|
|
|
|
2021-03-30 01:16:43 -07:00
|
|
|
if minetest.get_modpath("mesecons_switch") == nil then return end
|
2017-02-02 07:40:51 -08:00
|
|
|
|
|
|
|
minetest.override_item("mesecons_switch:mesecon_switch_off", {
|
|
|
|
groups = {
|
|
|
|
dig_immediate=2,
|
2020-11-23 14:02:55 -08:00
|
|
|
save_in_at_nodedb=1,
|
2017-02-02 07:40:51 -08:00
|
|
|
},
|
|
|
|
on_rightclick = function (pos, node)
|
2017-02-20 02:31:14 -08:00
|
|
|
advtrains.ndb.swap_node(pos, {name="mesecons_switch:mesecon_switch_on", param2=node.param2})
|
|
|
|
mesecon.receptor_on(pos)
|
2017-02-02 07:40:51 -08:00
|
|
|
minetest.sound_play("mesecons_switch", {pos=pos})
|
|
|
|
end,
|
2020-07-07 05:25:47 -07:00
|
|
|
advtrains = {
|
2017-02-02 07:40:51 -08:00
|
|
|
getstate = "off",
|
|
|
|
setstate = function(pos, node, newstate)
|
|
|
|
if newstate=="on" then
|
|
|
|
advtrains.ndb.swap_node(pos, {name="mesecons_switch:mesecon_switch_on", param2=node.param2})
|
2021-02-04 03:35:24 -08:00
|
|
|
if advtrains.is_node_loaded(pos) then
|
|
|
|
mesecon.receptor_on(pos)
|
|
|
|
end
|
2017-02-02 07:40:51 -08:00
|
|
|
end
|
|
|
|
end,
|
2021-02-04 03:35:24 -08:00
|
|
|
on_updated_from_nodedb = function(pos, node)
|
|
|
|
mesecon.receptor_off(pos)
|
|
|
|
end,
|
2017-02-02 07:40:51 -08:00
|
|
|
},
|
|
|
|
})
|
|
|
|
|
|
|
|
minetest.override_item("mesecons_switch:mesecon_switch_on", {
|
|
|
|
groups = {
|
|
|
|
dig_immediate=2,
|
2020-11-23 14:02:55 -08:00
|
|
|
save_in_at_nodedb=1,
|
2017-02-20 02:31:14 -08:00
|
|
|
not_in_creative_inventory=1,
|
2017-02-02 07:40:51 -08:00
|
|
|
},
|
|
|
|
on_rightclick = function (pos, node)
|
2017-02-20 02:31:14 -08:00
|
|
|
advtrains.ndb.swap_node(pos, {name="mesecons_switch:mesecon_switch_off", param2=node.param2})
|
|
|
|
mesecon.receptor_off(pos)
|
2017-02-02 07:40:51 -08:00
|
|
|
minetest.sound_play("mesecons_switch", {pos=pos})
|
|
|
|
end,
|
2020-07-07 05:25:47 -07:00
|
|
|
advtrains = {
|
2017-02-02 07:40:51 -08:00
|
|
|
getstate = "on",
|
|
|
|
setstate = function(pos, node, newstate)
|
|
|
|
if newstate=="off" then
|
|
|
|
advtrains.ndb.swap_node(pos, {name="mesecons_switch:mesecon_switch_off", param2=node.param2})
|
2021-02-04 03:35:24 -08:00
|
|
|
if advtrains.is_node_loaded(pos) then
|
|
|
|
mesecon.receptor_off(pos)
|
|
|
|
end
|
2017-02-02 07:40:51 -08:00
|
|
|
end
|
|
|
|
end,
|
2020-07-07 05:25:47 -07:00
|
|
|
fallback_state = "off",
|
2021-02-04 03:35:24 -08:00
|
|
|
on_updated_from_nodedb = function(pos, node)
|
|
|
|
mesecon.receptor_on(pos)
|
|
|
|
end,
|
2017-02-02 07:40:51 -08:00
|
|
|
},
|
|
|
|
})
|