aboutsummaryrefslogtreecommitdiff
path: root/advtrains_interlocking
diff options
context:
one' style='width: 99.6%;'/> -rw-r--r--advtrains_interlocking/init.lua10
-rw-r--r--advtrains_interlocking/models/at_il_tcb_node.obj248
-rw-r--r--advtrains_interlocking/signal_api.lua75
-rw-r--r--advtrains_interlocking/textures/at_il_signal_asp_danger.pngbin0 -> 247 bytes-rw-r--r--advtrains_interlocking/textures/at_il_signal_asp_free.pngbin0 -> 245 bytes-rw-r--r--advtrains_interlocking/textures/at_il_signal_asp_slow.pngbin0 -> 245 bytes-rw-r--r--advtrains_interlocking/textures/at_il_signal_off.pngbin0 -> 236 bytes-rw-r--r--advtrains_interlocking/textures/at_il_tcb_marker.pngbin0 -> 308 bytes-rw-r--r--advtrains_interlocking/textures/at_il_tcb_node.pngbin0 -> 279 bytes
12 files changed, 437 insertions, 4 deletions
diff --git a/advtrains_interlocking/database.lua b/advtrains_interlocking/database.lua
index 7a49383..61bf5ad 100644
--- a/advtrains_interlocking/database.lua
+++ b/advtrains_interlocking/database.lua
@@ -5,8 +5,7 @@ The interlocking system is based on track circuits.
Track circuit breaks must be manually set by the user. Signals must be assigned to track circuit breaks and to a direction(connid).
To simplify the whole system, there is no overlap.
== Trains ==
-A train always reserves the space between two signals facing it. All track circuits in this space
-have a reservation entry TRAIN with the train's ID
+Trains always occupy certain track circuits. These are shown red in the signalbox view (TRAIN occupation entry).
== Database storage ==
The things that are actually saved are the Track Circuit Breaks. Each TCB holds a list of the TCBs that are adjacent in each direction.
TC occupation/state is then saved inside each (TCB,Direction) and held in sync across all TCBs adjacent to this one. If something should not be in sync,
@@ -21,6 +20,8 @@ A track circuit does not have a state as such, but has more or less a list of "r
type can be one of these:
TRAIN See Trains obove
ROUTE Route set from a signal, but no train has yet passed that signal.
+Not implemented (see note by reversible): OWNED - former ROUTE segments that a train has begun passing (train_id assigned)
+ - Space behind a train up to the next signal, when a TC is set as REVERSIBLE
Certain TCs can be marked as "allow call-on".
== Route setting: ==
Routes are set from a signal (the entry signal) to another signal facing the same direction (the exit signal)
@@ -35,8 +36,17 @@ Apart from this, we need to set turnouts
It will be necessary to join and split trains using call-on routes. A call-on route may be set when:
- there are no ROUTE reservations
- there are TRAIN reservations only inside TCs that have "allow call-on" set
-
-
+== TC Properties ==
+Note: Reversible property will not be implemented, assuming everything as non-rev.
+This is sufficient to cover all use cases, and is done this way in reality.
+ REVERSIBLE - Whether trains are allowed to reverse while on track circuit
+ This property is supposed to be set for station tracks, where there is a signal at each end, and for sidings.
+ It should in no case be set for TCs covering turnouts, or for main running lines.
+ When a TC is not set as reversible, the OWNED status is cleared from the TC right after the train left it,
+ to allow other trains to pass it.
+ If it is set reversible, interlocking will keep the OWNED state behind the train up to the next signal, clearing it
+ as soon as the train passes another signal or enters a non-reversible section.
+CALL_ON_ALLOWED - Whether this TC being blocked (TRAIN or ROUTE) does not prevent shunt routes being set through this TC
== More notes ==
- It may not be possible to switch turnouts when their TC has any state entry
diff --git a/advtrains_interlocking/demosignals.lua b/advtrains_interlocking/demosignals.lua
new file mode 100644
index 0000000..8320afb
--- /dev/null
+++ b/advtrains_interlocking/demosignals.lua
@@ -0,0 +1,89 @@
+-- Demonstration signals
+-- Those can display the 3 main aspects of Ks signals
+
+
+minetest.register_node("advtrains_interlocking:ds_danger", {
+ description = "Demo signal at Danger",
+ tiles = {"at_il_signal_asp_danger.png"},
+ groups = {
+ cracky = 3,
+ advtrains_signal = 1,
+ save_in_at_nodedb = 1,
+ },
+ sounds = default.node_sound_stone_defaults(),
+ advtrains = {
+ set_aspect = function(pos, node, asp)
+ if asp.main.free then
+ if asp.dst.free and asp.main.speed > 50 then
+ advtrains.ndb.swap_node(pos, {name="advtrains_interlocking:ds_free"})
+ else
+ advtrains.ndb.swap_node(pos, {name="advtrains_interlocking:ds_slow"})
+ end
+ else
+ advtrains.ndb.swap_node(pos, {name="advtrains_interlocking:ds_danger"})
+ end
+ local meta = minetest.get_meta(pos)
+ if meta then
+ meta:set_string("infotext", minetest.serialize(asp))
+ end
+ end
+ },
+ on_rightclick = advtrains.interlocking.signal_rc_handler
+})
+minetest.register_node("advtrains_interlocking:ds_free", {
+ description = "Demo signal at Free",
+ tiles = {"at_il_signal_asp_free.png"},
+ groups = {
+ cracky = 3,
+ advtrains_signal = 1,
+ save_in_at_nodedb = 1,
+ },
+ sounds = default.node_sound_stone_defaults(),
+ advtrains = {
+ set_aspect = function(pos, node, asp)
+ if asp.main.free then
+ if asp.dst.free and asp.main.speed > 50 then
+ advtrains.ndb.swap_node(pos, {name="advtrains_interlocking:ds_free"})
+ else
+ advtrains.ndb.swap_node(pos, {name="advtrains_interlocking:ds_slow"})
+ end
+ else
+ advtrains.ndb.swap_node(pos, {name="advtrains_interlocking:ds_danger"})
+ end
+ local meta = minetest.get_meta(pos)
+ if meta then
+ meta:set_string("infotext", minetest.serialize(asp))
+ end
+ end
+ },
+ on_rightclick = advtrains.interlocking.signal_rc_handler
+})
+minetest.register_node("advtrains_interlocking:ds_slow", {
+ description = "Demo signal at Slow",
+ tiles = {"at_il_signal_asp_slow.png"},
+ groups = {
+ cracky = 3,
+ advtrains_signal = 1,
+ save_in_at_nodedb = 1,
+ },
+ sounds = default.node_sound_stone_defaults(),
+ advtrains = {
+ set_aspect = function(pos, node, asp)
+ if asp.main.free then
+ if asp.dst.free and asp.main.speed > 50 then
+ advtrains.ndb.swap_node(pos, {name="advtrains_interlocking:ds_free"})
+ else
+ advtrains.ndb.swap_node(pos, {name="advtrains_interlocking:ds_slow"})
+ end
+ else
+ advtrains.ndb.swap_node(pos, {name="advtrains_interlocking:ds_danger"})
+ end
+ local meta = minetest.get_meta(pos)
+ if meta then
+ meta:set_string("infotext", minetest.serialize(asp))
+ end
+ end
+ },
+ on_rightclick = advtrains.interlocking.signal_rc_handler
+})
+
diff --git a/advtrains_interlocking/depends.txt b/advtrains_interlocking/depends.txt
new file mode 100644
index 0000000..6f00bf6
--- /dev/null
+++ b/advtrains_interlocking/depends.txt
@@ -0,0 +1 @@
+advtrains \ No newline at end of file
diff --git a/advtrains_interlocking/init.lua b/advtrains_interlocking/init.lua
index e69de29..ab79573 100644
--- a/advtrains_interlocking/init.lua
+++ b/advtrains_interlocking/init.lua
@@ -0,0 +1,10 @@
+-- Advtrains interlocking system
+-- See database.lua for a detailed explanation
+
+advtrains.interlocking = {}
+
+local modpath = minetest.get_modpath(minetest.get_current_modname()) .. DIR_DELIM
+
+dofile(modpath.."database.lua")
+dofile(modpath.."signal_api.lua")
+dofile(modpath.."demosignals.lua")
diff --git a/advtrains_interlocking/models/at_il_tcb_node.obj b/advtrains_interlocking/models/at_il_tcb_node.obj
new file mode 100644
index 0000000..bb6aab5
--- /dev/null
+++ b/advtrains_interlocking/models/at_il_tcb_node.obj
@@ -0,0 +1,248 @@
+# Blender v2.76 (sub 0) OBJ File: ''
+# www.blender.org
+mtllib at_il_tcb_node.mtl
+o Cube
+v 0.038370 -0.500000 -0.038370
+v 0.038370 -0.500000 0.038370
+v -0.038370 -0.500000 0.038370
+v -0.038370 -0.500000 -0.038370
+v 0.038370 0.098086 -0.038370
+v 0.038370 0.098086 0.038370
+v -0.038370 0.098086 0.038370
+v -0.038370 0.098086 -0.038370
+v -0.182395 0.065479 0.099357
+v -0.182395 0.182395 0.099357
+v -0.182395 0.065479 -0.171034
+v -0.182395 0.182395 -0.171034
+v 0.182395 0.065479 0.099357
+v 0.182395 0.182395 0.099357
+v 0.182395 0.065479 -0.171034
+v 0.182395 0.182395 -0.171034
+v -0.112374 0.070035 -0.139406
+v -0.112374 -0.500000 -0.139406
+v 0.112189 -0.500000 -0.139406
+v 0.112189 0.070035 -0.139406
+v 0.122883 -0.500000 -0.137278
+v 0.122883 0.070035 -0.137278
+v 0.131950 -0.500000 -0.131220
+v 0.131950 0.070035 -0.131220
+v 0.138008 -0.500000 -0.122154
+v 0.138008 0.070035 -0.122154
+v 0.140135 -0.500000 -0.111459
+v 0.140135 0.070035 -0.111459
+v 0.138008 -0.500000 -0.100765
+v 0.138008 0.070035 -0.100765
+v 0.131950 -0.500000 -0.091698
+v 0.131950 0.070035 -0.091698
+v 0.122883 -0.500000 -0.085640
+v 0.122883 0.070035 -0.085640
+v 0.112189 -0.500000 -0.083513
+v 0.112189 0.070035 -0.083513
+v 0.101494 -0.500000 -0.085640
+v 0.101494 0.070035 -0.085640
+v 0.092428 -0.500000 -0.091698
+v 0.092428 0.070035 -0.091698
+v 0.086370 -0.500000 -0.100765
+v 0.086370 0.070035 -0.100765
+v 0.084242 -0.500000 -0.111459
+v 0.084242 0.070035 -0.111459
+v 0.086370 -0.500000 -0.122154
+v 0.086370 0.070035 -0.122154
+v 0.092428 -0.500000 -0.131220
+v 0.092428 0.070035 -0.131220
+v 0.101494 -0.500000 -0.137278
+v 0.101494 0.070035 -0.137278
+v -0.101679 -0.500000 -0.137278
+v -0.101679 0.070035 -0.137278
+v -0.092613 -0.500000 -0.131220
+v -0.092613 0.070035 -0.131220
+v -0.086555 -0.500000 -0.122154
+v -0.086555 0.070035 -0.122154
+v -0.084428 -0.500000 -0.111459
+v -0.084428 0.070035 -0.111459
+v -0.086555 -0.500000 -0.100765
+v -0.086555 0.070035 -0.100765
+v -0.092613 -0.500000 -0.091698
+v -0.092613 0.070035 -0.091698
+v -0.101679 -0.500000 -0.085640
+v -0.101679 0.070035 -0.085640
+v -0.112374 -0.500000 -0.083513
+v -0.112374 0.070035 -0.083513
+v -0.123069 -0.500000 -0.085640
+v -0.123069 0.070035 -0.085640
+v -0.132135 -0.500000 -0.091698
+v -0.132135 0.070035 -0.091698
+v -0.138193 -0.500000 -0.100765
+v -0.138193 0.070035 -0.100765
+v -0.140320 -0.500000 -0.111459
+v -0.140320 0.070035 -0.111459
+v -0.138193 -0.500000 -0.122154
+v -0.138193 0.070035 -0.122154
+v -0.132135 -0.500000 -0.131220
+v -0.132135 0.070035 -0.131220
+v -0.123069 -0.500000 -0.137278
+v -0.123069 0.070035 -0.137278
+vt 0.876073 0.266665
+vt 0.876073 0.977812
+vt 0.784827 0.977812
+vt 0.784827 0.266665
+vt 0.693582 0.977812
+vt 0.693582 0.266665
+vt 0.602336 0.977812
+vt 0.602336 0.266665
+vt 0.967319 0.266665
+vt 0.967319 0.977812
+vt 0.147929 0.032040