aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authororwell96 <orwell@bleipb.de>2019-01-24 13:43:22 +0100
committerorwell96 <orwell@bleipb.de>2019-01-24 13:43:22 +0100
commit2976bae4522a1682808db55473d9f824c7155cc6 (patch)
tree18cbfebbbf2d46a005499f8255b902b7e6c5e3da
parent1c3ea960415fcbd63c5f1b2cd8a5b25f79d2879f (diff)
downloadadvtrains-2976bae4522a1682808db55473d9f824c7155cc6.tar.gz
advtrains-2976bae4522a1682808db55473d9f824c7155cc6.tar.bz2
advtrains-2976bae4522a1682808db55473d9f824c7155cc6.zip
Point speed restriction rails
-rw-r--r--advtrains/trainlogic.lua4
-rw-r--r--advtrains_interlocking/database.lua6
-rw-r--r--advtrains_interlocking/init.lua1
-rw-r--r--advtrains_interlocking/textures/advtrains_dtrack_npr_placer.pngbin0 -> 1238 bytes
-rw-r--r--advtrains_interlocking/textures/advtrains_dtrack_shared_npr.pngbin0 -> 3176 bytes
-rw-r--r--advtrains_interlocking/tsr_rail.lua54
-rw-r--r--advtrains_line_automation/init.lua24
7 files changed, 84 insertions, 5 deletions
diff --git a/advtrains/trainlogic.lua b/advtrains/trainlogic.lua
index 94d5980..ad51c42 100644
--- a/advtrains/trainlogic.lua
+++ b/advtrains/trainlogic.lua
@@ -474,8 +474,8 @@ function advtrains.train_step_b(id, train, dtime)
local pdist = train.path_dist[math.floor(train.index)] or 1
local distance = (train.velocity*dtime) / pdist
- --TODO debugging code
- train.debug = atdump(train.ctrl).."step_dist: "..math.floor(distance*1000)
+ --debugging code
+ --train.debug = atdump(train.ctrl).."step_dist: "..math.floor(distance*1000)
train.index=train.index+distance
diff --git a/advtrains_interlocking/database.lua b/advtrains_interlocking/database.lua
index 4aaa4c4..ba2a318 100644
--- a/advtrains_interlocking/database.lua
+++ b/advtrains_interlocking/database.lua
@@ -105,6 +105,8 @@ local signal_assignments = {}
-- track+direction -> signal position
local influence_points = {}
+advtrains.interlocking.npr_rails = {}
+
function ildb.load(data)
if not data then return end
@@ -126,6 +128,9 @@ function ildb.load(data)
if data.influence_points then
influence_points = data.influence_points
end
+ if data.npr_rails then
+ advtrains.interlocking.npr_rails = data.npr_rails
+ end
end
function ildb.save()
@@ -136,6 +141,7 @@ function ildb.save()
rs_locks = advtrains.interlocking.route.rte_locks,
rs_callbacks = advtrains.interlocking.route.rte_callbacks,
influence_points = influence_points,
+ npr_rails = advtrains.interlocking.npr_rails,
}
end
diff --git a/advtrains_interlocking/init.lua b/advtrains_interlocking/init.lua
index aa498df..37f962b 100644
--- a/advtrains_interlocking/init.lua
+++ b/advtrains_interlocking/init.lua
@@ -24,6 +24,7 @@ dofile(modpath.."tool.lua")
dofile(modpath.."lzb.lua")
dofile(modpath.."ars.lua")
+dofile(modpath.."tsr_rail.lua")
minetest.register_privilege("interlocking", {description = "Can set up track sections, routes and signals.", give_to_singleplayer = true})
diff --git a/advtrains_interlocking/textures/advtrains_dtrack_npr_placer.png b/advtrains_interlocking/textures/advtrains_dtrack_npr_placer.png
new file mode 100644
index 0000000..0d1c769
--- /dev/null
+++ b/advtrains_interlocking/textures/advtrains_dtrack_npr_placer.png
Binary files differ
diff --git a/advtrains_interlocking/textures/advtrains_dtrack_shared_npr.png b/advtrains_interlocking/textures/advtrains_dtrack_shared_npr.png
new file mode 100644
index 0000000..0116c27
--- /dev/null
+++ b/advtrains_interlocking/textures/advtrains_dtrack_shared_npr.png
Binary files differ
diff --git a/advtrains_interlocking/tsr_rail.lua b/advtrains_interlocking/tsr_rail.lua
new file mode 100644
index 0000000..253298c
--- /dev/null
+++ b/advtrains_interlocking/tsr_rail.lua
@@ -0,0 +1,54 @@
+-- tsr_rail.lua
+-- Point speed restriction rails
+-- Simple rail whose only purpose is to place a TSR on the position, as a temporary solution until the timetable system covers everything.
+
+local function updateform(pos)
+ local meta = minetest.get_meta(pos)
+ local pe = advtrains.encode_pos(pos)
+ local npr = advtrains.interlocking.npr_rails[pe] or 2
+
+ meta:set_string("infotext", "Point speed restriction: "..npr)
+ meta:set_string("formspec", "field[npr;Set point speed restriction:;"..npr.."]")
+end
+
+
+local adefunc = function(def, preset, suffix, rotation)
+ return {
+ after_place_node=function(pos)
+ updateform(pos)
+ end,
+ after_dig_node=function(pos)
+ local pe = advtrains.encode_pos(pos)
+ advtrains.interlocking.npr_rails[pe] = nil
+ end,
+ on_receive_fields = function(pos, formname, fields, player)
+ if fields.npr then
+ local pe = advtrains.encode_pos(pos)
+ advtrains.interlocking.npr_rails[pe] = tonumber(fields.npr)
+ updateform(pos)
+ end
+ end,
+ advtrains = {
+ on_train_approach = function(pos,train_id, train, index)
+ if train.path_cn[index] == 1 then
+ local pe = advtrains.encode_pos(pos)
+ local npr = advtrains.interlocking.npr_rails[pe] or 2
+ advtrains.interlocking.lzb_add_oncoming_npr(train, index, npr)
+ end
+ end,
+ },
+ }
+end
+
+
+
+advtrains.register_tracks("default", {
+ nodename_prefix="advtrains_interlocking:dtrack_npr",
+ texture_prefix="advtrains_dtrack_npr",
+ models_prefix="advtrains_dtrack",
+ models_suffix=".b3d",
+ shared_texture="advtrains_dtrack_shared_npr.png",
+ description="Point Speed Restriction Rail",
+ formats={},
+ get_additional_definiton = adefunc,
+}, advtrains.trackpresets.t_30deg_straightonly)
diff --git a/advtrains_line_automation/init.lua b/advtrains_line_automation/init.lua
index 5521ee9..77e66b3 100644
--- a/advtrains_line_automation/init.lua
+++ b/advtrains_line_automation/init.lua
@@ -1,6 +1,18 @@
-- Advtrains line automation system
-advtrains.lines = {}
+advtrains.lines = {
+ -- [station code] = {name=...}
+ stations = {},
+
+ --[[ [new pos hash] = {
+ stn = <station code>,
+ platform = <platform identifier>,
+ doors = <door side L,R,C>
+ wait = <least wait time>
+ signal = <position of signal that is the "exit signal" for this platform>
+ }]]
+ stops = {},
+}
local modpath = minetest.get_modpath(minetest.get_current_modname()) .. DIR_DELIM
@@ -9,9 +21,15 @@ dofile(modpath.."stoprail.lua")
function advtrains.lines.load(data)
-
+ if data then
+ advtrains.lines.stations = data.stations or {}
+ advtrains.lines.stops = data.stops or {}
+ end
end
function advtrains.lines.save()
- return {}
+ return {
+ stations = advtrains.lines.stations,
+ stops = advtrains.lines.stops
+ }
end