aboutsummaryrefslogtreecommitdiff
path: root/advtrains_interlocking/route_prog.lua
diff options
context:
space:
mode:
authororwell96 <orwell@bleipb.de>2018-07-04 19:31:44 +0200
committerorwell96 <orwell@bleipb.de>2018-07-04 19:31:44 +0200
commite3667b630c6c232f012bbebc3a72c751c085d416 (patch)
tree39dc02ea0a0a0fd6d3008a01ff6a9bc014143956 /advtrains_interlocking/route_prog.lua
parent031aab4633f6f140a2ffda4f00b6e0d743cf681a (diff)
downloadadvtrains-e3667b630c6c232f012bbebc3a72c751c085d416.tar.gz
advtrains-e3667b630c6c232f012bbebc3a72c751c085d416.tar.bz2
advtrains-e3667b630c6c232f012bbebc3a72c751c085d416.zip
Basic route management from signalling formspec
Diffstat (limited to 'advtrains_interlocking/route_prog.lua')
-rw-r--r--advtrains_interlocking/route_prog.lua21
1 files changed, 19 insertions, 2 deletions
diff --git a/advtrains_interlocking/route_prog.lua b/advtrains_interlocking/route_prog.lua
index 72f72ca..e67abd7 100644
--- a/advtrains_interlocking/route_prog.lua
+++ b/advtrains_interlocking/route_prog.lua
@@ -126,6 +126,14 @@ end
-- e.g. prog_<player> or vis<pts> for later visualizations
function advtrains.interlocking.visualize_route(origin, route, context)
advtrains.interlocking.clear_visu_context(context)
+
+ local oyaw = 0
+ local onode_ok, oconns, orhe = advtrains.get_rail_info_at(origin.p, advtrains.all_tracktypes)
+ if onode_ok then
+ oyaw = advtrains.dir_to_angle(oconns[origin.s].c)
+ end
+ routemarker(context, origin.p, "rte_origin", "at_il_route_start.png", oyaw, route.name)
+
for k,sigd in ipairs(route.tcbpath) do
local yaw = 0
local node_ok, conns, rhe = advtrains.get_rail_info_at(sigd.p, advtrains.all_tracktypes)
@@ -154,7 +162,9 @@ function advtrains.interlocking.init_route_prog(pname, sigd)
pcfix = {},
}
}
+ advtrains.interlocking.visualize_route(sigd, player_rte_prog[pname].route, "prog_"..pname)
minetest.chat_send_player(pname, "Route programming mode active. Punch TCBs to add route segments, punch turnouts to lock them.")
+ minetest.chat_send_player(pname, "Type /at_rp_set <name> when you are done, /at_rp_discard to cancel route programming")
end
local function get_last_route_item(origin, route)
@@ -255,9 +265,16 @@ minetest.register_chatcommand("at_rp_set",
return false, "Cannot program route without a target"
end
rp.route.name = param
- -- TODO save that route somewhere in origin
- atdebug("ROUTE RESULT:",rp)
+
+ local tcbs = advtrains.interlocking.db.get_tcbs(rp.origin)
+ if not tcbs then
+ return false, "The origin TCB of this route doesn't exist!"
+ end
+
+ table.insert(tcbs.routes, rp.route)
+
advtrains.interlocking.clear_visu_context("prog_"..pname)
+ player_rte_prog[pname] = nil
return true, "Successfully programmed route"
end
return false, "You were not programming a route!"