aboutsummaryrefslogtreecommitdiff
path: root/advtrains/p_mesecon_iface.lua
diff options
context:
space:
mode:
authororwell96 <orwell@bleipb.de>2021-02-04 12:35:24 +0100
committerorwell96 <orwell@bleipb.de>2021-02-04 12:35:24 +0100
commite935136d58dc863541a6a53c6f5e9f9d218e6661 (patch)
tree50d1dea4941799bd095e920fb1e89c493d7d283b /advtrains/p_mesecon_iface.lua
parent8ae405f00f7073bca8cb621612ab11bc730228a3 (diff)
downloadadvtrains-e935136d58dc863541a6a53c6f5e9f9d218e6661.tar.gz
advtrains-e935136d58dc863541a6a53c6f5e9f9d218e6661.tar.bz2
advtrains-e935136d58dc863541a6a53c6f5e9f9d218e6661.zip
Make is_node_loaded() checks also for mesecon interactions and digiline_send(), move on_updated_from_nodedb to advtrains table
Diffstat (limited to 'advtrains/p_mesecon_iface.lua')
-rw-r--r--advtrains/p_mesecon_iface.lua20
1 files changed, 12 insertions, 8 deletions
diff --git a/advtrains/p_mesecon_iface.lua b/advtrains/p_mesecon_iface.lua
index 177112e..0eef96a 100644
--- a/advtrains/p_mesecon_iface.lua
+++ b/advtrains/p_mesecon_iface.lua
@@ -13,17 +13,19 @@ minetest.override_item("mesecons_switch:mesecon_switch_off", {
mesecon.receptor_on(pos)
minetest.sound_play("mesecons_switch", {pos=pos})
end,
- on_updated_from_nodedb = function(pos, node)
- mesecon.receptor_off(pos)
- end,
advtrains = {
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})
- mesecon.receptor_on(pos)
+ if advtrains.is_node_loaded(pos) then
+ mesecon.receptor_on(pos)
+ end
end
end,
+ on_updated_from_nodedb = function(pos, node)
+ mesecon.receptor_off(pos)
+ end,
},
})
@@ -38,17 +40,19 @@ minetest.override_item("mesecons_switch:mesecon_switch_on", {
mesecon.receptor_off(pos)
minetest.sound_play("mesecons_switch", {pos=pos})
end,
- on_updated_from_nodedb = function(pos, node)
- mesecon.receptor_on(pos)
- end,
advtrains = {
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})
- mesecon.receptor_off(pos)
+ if advtrains.is_node_loaded(pos) then
+ mesecon.receptor_off(pos)
+ end
end
end,
fallback_state = "off",
+ on_updated_from_nodedb = function(pos, node)
+ mesecon.receptor_on(pos)
+ end,
},
})