aboutsummaryrefslogtreecommitdiff
path: root/advtrains_interlocking/tool.lua
diff options
context:
space:
mode:
authororwell <orwell@bleipb.de>2024-12-13 00:23:18 +0100
committerorwell <orwell@bleipb.de>2024-12-13 00:23:18 +0100
commit7d5f840579b74374698704f256479520bde25091 (patch)
treeb39e32d1b2f518656bb12f2b6641ad31967bac99 /advtrains_interlocking/tool.lua
parentfe620eccb283a9d6e15c8fdbf564e8e2142da749 (diff)
downloadadvtrains-7d5f840579b74374698704f256479520bde25091.tar.gz
advtrains-7d5f840579b74374698704f256479520bde25091.tar.bz2
advtrains-7d5f840579b74374698704f256479520bde25091.zip
Repair sections on smartroute, detect start!=end TS in routesetting, create section with IL tool aux1route_prog_rework
Diffstat (limited to 'advtrains_interlocking/tool.lua')
-rw-r--r--advtrains_interlocking/tool.lua16
1 files changed, 10 insertions, 6 deletions
diff --git a/advtrains_interlocking/tool.lua b/advtrains_interlocking/tool.lua
index 4ebc56c..560e129 100644
--- a/advtrains_interlocking/tool.lua
+++ b/advtrains_interlocking/tool.lua
@@ -3,7 +3,7 @@
local ilrs = advtrains.interlocking.route
-local function node_right_click(pos, pname)
+local function node_right_click(pos, pname, player)
if advtrains.is_passive(pos) then
local form = "size[7,5]label[0.5,0.5;Route lock inspector]"
local pts = advtrains.encode_pos(pos)
@@ -33,7 +33,7 @@ local function node_right_click(pos, pname)
return
end
- local ts_id = advtrains.interlocking.db.check_and_repair_ts_at_pos(pos)
+ local ts_id = advtrains.interlocking.db.check_and_repair_ts_at_pos(pos, nil, pname)
if ts_id then
advtrains.interlocking.show_ts_form(ts_id, pname)
else
@@ -41,7 +41,7 @@ local function node_right_click(pos, pname)
end
end
-local function node_left_click(pos, pname)
+local function node_left_click(pos, pname, player)
local node_ok, conns, rail_y=advtrains.get_rail_info_at(pos)
if not node_ok then
minetest.chat_send_player(pname, "Node is not a track!")
@@ -52,8 +52,12 @@ local function node_left_click(pos, pname)
advtrains.interlocking.show_tcb_marker(pos)
return
end
+
+ -- create track section if aux1 button down
+ local pc = player:get_player_control()
+ local force_create = pc.aux1
- local ts_id = advtrains.interlocking.db.check_and_repair_ts_at_pos(pos, nil, pname)
+ local ts_id = advtrains.interlocking.db.check_and_repair_ts_at_pos(pos, nil, pname, force_create)
if ts_id then
advtrains.interlocking.db.update_rs_cache(ts_id)
advtrains.interlocking.highlight_track_section(pos)
@@ -80,7 +84,7 @@ minetest.register_craftitem("advtrains_interlocking:tool",{
end
if pointed_thing.type=="node" then
local pos=pointed_thing.under
- node_right_click(pos, pname)
+ node_right_click(pos, pname, player)
end
end,
on_use = function(itemstack, player, pointed_thing)
@@ -94,7 +98,7 @@ minetest.register_craftitem("advtrains_interlocking:tool",{
end
if pointed_thing.type=="node" then
local pos=pointed_thing.under
- node_left_click(pos, pname)
+ node_left_click(pos, pname, player)
end
end
})