aboutsummaryrefslogtreecommitdiff
path: root/advtrains_interlocking
diff options
context:
space:
mode:
authororwell96 <orwell@bleipb.de>2019-02-16 13:09:33 +0100
committerorwell96 <orwell@bleipb.de>2019-02-16 13:09:33 +0100
commitee079d02ff09c4ae4bc63d892e83146dfe6edd6c (patch)
tree833710c1cdfdcc857a2fe144db41c45aab030188 /advtrains_interlocking
parentaa2b08b9853261e5e674348ffe122736dbd02b0b (diff)
downloadadvtrains-ee079d02ff09c4ae4bc63d892e83146dfe6edd6c.tar.gz
advtrains-ee079d02ff09c4ae4bc63d892e83146dfe6edd6c.tar.bz2
advtrains-ee079d02ff09c4ae4bc63d892e83146dfe6edd6c.zip
Improve Signal IP form/workflow
Diffstat (limited to 'advtrains_interlocking')
-rw-r--r--advtrains_interlocking/signal_api.lua39
-rw-r--r--advtrains_interlocking/train_sections.lua2
2 files changed, 19 insertions, 22 deletions
diff --git a/advtrains_interlocking/signal_api.lua b/advtrains_interlocking/signal_api.lua
index f33edde..6704e18 100644
--- a/advtrains_interlocking/signal_api.lua
+++ b/advtrains_interlocking/signal_api.lua
@@ -322,6 +322,20 @@ end
local players_assign_ip = {}
+local function ipmarker(ipos, connid)
+ local node_ok, conns, rhe = advtrains.get_rail_info_at(ipos, advtrains.all_tracktypes)
+ if not node_ok then return end
+ local yaw = advtrains.dir_to_angle(conns[connid].c)
+
+ -- using tcbmarker here
+ local obj = minetest.add_entity(vector.add(ipos, {x=0, y=0.2, z=0}), "advtrains_interlocking:tcbmarker")
+ if not obj then return end
+ obj:set_yaw(yaw)
+ obj:set_properties({
+ textures = { "at_il_signal_ip.png" },
+ })
+end
+
-- shows small info form for signal IP state/assignment
-- only_notset: show only if it is not set yet (used by signal tcb assignment)
function advtrains.interlocking.show_ip_form(pos, pname, only_notset)
@@ -332,8 +346,10 @@ function advtrains.interlocking.show_ip_form(pos, pname, only_notset)
local pts, connid = advtrains.interlocking.db.get_ip_by_signalpos(pos)
if pts then
form = form.."label[0.5,1.5;Influence point is set at "..pts.."/"..connid.."]"
- form = form.."button_exit[0.5,2.5; 5,1;show;Show]"
+ form = form.."button_exit[0.5,2.5; 5,1;set;Move]"
form = form.."button_exit[0.5,3.5; 5,1;clear;Clear]"
+ local ipos = minetest.string_to_pos(pts)
+ ipmarker(ipos, connid)
else
form = form.."label[0.5,1.5;Influence point is not set.]"
form = form.."label[0.5,2.0;It is recommended to set an influence point.]"
@@ -346,20 +362,6 @@ function advtrains.interlocking.show_ip_form(pos, pname, only_notset)
end
end
-local function ipmarker(ipos, connid)
- local node_ok, conns, rhe = advtrains.get_rail_info_at(ipos, advtrains.all_tracktypes)
- if not node_ok then return end
- local yaw = advtrains.dir_to_angle(conns[connid].c)
-
- -- using tcbmarker here
- local obj = minetest.add_entity(vector.add(ipos, {x=0, y=0.2, z=0}), "advtrains_interlocking:tcbmarker")
- if not obj then return end
- obj:set_yaw(yaw)
- obj:set_properties({
- textures = { "at_il_signal_ip.png" },
- })
-end
-
minetest.register_on_player_receive_fields(function(player, formname, fields)
local pname = player:get_player_name()
if not minetest.check_player_privs(pname, {train_operator=true, interlocking=true}) then
@@ -375,11 +377,6 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
advtrains.interlocking.signal_init_ip_assign(pos, pname)
elseif fields.clear then
advtrains.interlocking.db.clear_ip_by_signalpos(pos)
- elseif fields.show then
- local ipts, connid = advtrains.interlocking.db.get_ip_by_signalpos(pos)
- if not ipts then return end
- local ipos = minetest.string_to_pos(ipts)
- ipmarker(ipos, connid)
end
end
end)
@@ -391,7 +388,7 @@ function advtrains.interlocking.signal_init_ip_assign(pos, pname)
return
end
--remove old IP
- advtrains.interlocking.db.clear_ip_by_signalpos(pos)
+ --advtrains.interlocking.db.clear_ip_by_signalpos(pos)
minetest.chat_send_player(pname, "Configuring Signal: Please look in train's driving direction and punch rail to set influence point.")
players_assign_ip[pname] = pos
diff --git a/advtrains_interlocking/train_sections.lua b/advtrains_interlocking/train_sections.lua
index 21d3d13..757f36a 100644
--- a/advtrains_interlocking/train_sections.lua
+++ b/advtrains_interlocking/train_sections.lua
@@ -65,7 +65,7 @@ local function setsection(tid, train, ts_id, ts, sigd)
-- train
if not train.il_sections then train.il_sections = {} end
if not itkexist(train.il_sections, "ts_id", ts_id) then
- table.insert(train.il_sections, {ts_id = ts_id, origin = origin})
+ table.insert(train.il_sections, {ts_id = ts_id, origin = sigd})
end
-- ts