aboutsummaryrefslogtreecommitdiff
path: root/advtrains
diff options
context:
space:
mode:
Diffstat (limited to 'advtrains')
-rw-r--r--advtrains/p_mesecon_iface.lua24
-rw-r--r--advtrains/passive.lua6
-rw-r--r--advtrains/signals.lua47
3 files changed, 36 insertions, 41 deletions
diff --git a/advtrains/p_mesecon_iface.lua b/advtrains/p_mesecon_iface.lua
index 33fcecd..0b99891 100644
--- a/advtrains/p_mesecon_iface.lua
+++ b/advtrains/p_mesecon_iface.lua
@@ -14,13 +14,11 @@ minetest.override_item("mesecons_switch:mesecon_switch_off", {
minetest.sound_play("mesecons_switch", {pos=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})
- if advtrains.is_node_loaded(pos) then
- mesecon.receptor_on(pos)
- end
+ node_state = "off",
+ node_state_map = { on = "mesecons_switch:mesecon_switch_on", off = "mesecons_switch:mesecon_switch_off" },
+ node_on_switch_state = function(pos, new_node, old_state, new_state)
+ if advtrains.is_node_loaded(pos) then
+ mesecon.receptor_on(pos)
end
end,
on_updated_from_nodedb = function(pos, node)
@@ -41,13 +39,11 @@ minetest.override_item("mesecons_switch:mesecon_switch_on", {
minetest.sound_play("mesecons_switch", {pos=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})
- if advtrains.is_node_loaded(pos) then
- mesecon.receptor_off(pos)
- end
+ node_state = "on",
+ node_state_map = { on = "mesecons_switch:mesecon_switch_on", off = "mesecons_switch:mesecon_switch_off" },
+ node_on_switch_state = function(pos, new_node, old_state, new_state)
+ if advtrains.is_node_loaded(pos) then
+ mesecon.receptor_off(pos)
end
end,
fallback_state = "off",
diff --git a/advtrains/passive.lua b/advtrains/passive.lua
index aad309e..37b79e4 100644
--- a/advtrains/passive.lua
+++ b/advtrains/passive.lua
@@ -70,12 +70,6 @@ function advtrains.setstate(parpos, newstate, pnode)
end
-- invalidate paths (only relevant if this is a track)
advtrains.invalidate_all_paths(pos)
- -- hack for old signals. Compatibility only, DO NOT USE for new signals!
- if advtrains.interlocking and ndef.advtrains._is_passivenode_signal then
- -- forcefully clears any set aspect, so that aspect system doesnt override it again
- -- implicitly does an signal.notify_trains(pos)
- advtrains.interlocking.signal.clear_aspect(pos)
- end
return true
end
diff --git a/advtrains/signals.lua b/advtrains/signals.lua
index 0b874bf..3f736c9 100644
--- a/advtrains/signals.lua
+++ b/advtrains/signals.lua
@@ -74,8 +74,9 @@ for r,f in pairs({on={as="off", ls="green", als="red"}, off={as="on", ls="red",
advtrains.ndb.swap_node(pos, {name = "advtrains:retrosignal_"..f.as..rotation, param2 = node.param2}, true)
if advtrains.interlocking then
-- forcefully clears any set aspect, so that aspect system doesnt override it again
- -- implicitly does an signal.notify_trains(pos)
- advtrains.interlocking.signal.clear_aspect(pos)
+ advtrains.interlocking.signal.unregister_aspect(pos)
+ -- notify trains
+ advtrains.interlocking.signal.notify_trains(pos)
end
end
}},
@@ -90,8 +91,9 @@ for r,f in pairs({on={as="off", ls="green", als="red"}, off={as="on", ls="red",
advtrains.ndb.swap_node(pos, {name = "advtrains:retrosignal_"..f.as..rotation, param2 = node.param2}, true)
if advtrains.interlocking then
-- forcefully clears any set aspect, so that aspect system doesnt override it again
- -- implicitly does an signal.notify_trains(pos)
- advtrains.interlocking.signal.clear_aspect(pos)
+ advtrains.interlocking.signal.unregister_aspect(pos)
+ -- notify trains
+ advtrains.interlocking.signal.notify_trains(pos)
end
end
end,
@@ -133,9 +135,6 @@ for r,f in pairs({on={as="off", ls="green", als="red"}, off={as="on", ls="red",
rules=advtrains.meseconrules,
["action_"..f.as] = function (pos, node)
advtrains.setstate(pos, f.als, node)
- if advtrains.interlocking then
- advtrains.interlocking.signal.notify_on_aspect_changed(pos)
- end
end
}},
on_rightclick=function(pos, node, player)
@@ -156,7 +155,14 @@ for r,f in pairs({on={as="off", ls="green", als="red"}, off={as="on", ls="red",
get_aspect_info = function() return aspect(r=="on") end,
node_state = f.ls,
node_state_map = { red = "advtrains:signal_off"..rotation, green = "advtrains:signal_on"..rotation},
- _is_passivenode_signal = true
+ node_on_switch_state = function(pos, new_node, old_state, new_state)
+ if advtrains.interlocking then
+ -- forcefully clears any set aspect, so that aspect system doesnt override it again
+ advtrains.interlocking.signal.unregister_aspect(pos)
+ -- notify trains
+ advtrains.interlocking.signal.notify_trains(pos)
+ end
+ end,
},
can_dig = can_dig_func,
after_dig_node = after_dig_func,
@@ -215,7 +221,14 @@ for r,f in pairs({on={as="off", ls="green", als="red"}, off={as="on", ls="red",
get_aspect_info = function() return aspect(r=="on") end,
node_state = f.ls,
node_state_map = { red = "advtrains:signal_wall_"..loc.."_off", green = "advtrains:signal_wall_"..loc.."_on" },
- _is_passivenode_signal = true
+ node_on_switch_state = function(pos, new_node, old_state, new_state)
+ if advtrains.interlocking then
+ -- forcefully clears any set aspect, so that aspect system doesnt override it again
+ advtrains.interlocking.signal.unregister_aspect(pos)
+ -- notify trains
+ advtrains.interlocking.signal.notify_trains(pos)
+ end
+ end,
},
can_dig = can_dig_func,
after_dig_node = after_dig_func,
@@ -253,12 +266,8 @@ minetest.register_node("advtrains:across_off", {
end
}},
advtrains = {
- getstate = "off",
- setstate = function(pos, node, newstate)
- if newstate == "on" then
- advtrains.ndb.swap_node(pos, {name = "advtrains:across_on", param2 = node.param2}, true)
- end
- end,
+ node_state = "off",
+ node_state_map = { on = "advtrains:across_on", off = "advtrains:across_off" },
},
on_rightclick=function(pos, node, player)
if advtrains.check_turnout_signal_protection(pos, player:get_player_name()) then
@@ -294,12 +303,8 @@ minetest.register_node("advtrains:across_on", {
end
}},
advtrains = {
- getstate = "on",
- setstate = function(pos, node, newstate)
- if newstate == "off" then
- advtrains.ndb.swap_node(pos, {name = "advtrains:across_off", param2 = node.param2}, true)
- end
- end,
+ node_state = "on",
+ node_state_map = { on = "advtrains:across_on", off = "advtrains:across_off" },
fallback_state = "off",
},
on_rightclick=function(pos, node, player)