aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authororwell96 <orwell@bleipb.de>2021-03-12 17:30:50 +0100
committerorwell96 <orwell@bleipb.de>2021-03-12 17:30:50 +0100
commit2dcf60dec6304abc910dea82c6f9a5904bbf365b (patch)
treeb534822e5f0d220b6d344b21719fc954ffdeec46
parent0c7beca20e5f97a2ef24334282d7615d92295ad0 (diff)
downloadadvtrains-2dcf60dec6304abc910dea82c6f9a5904bbf365b.tar.gz
advtrains-2dcf60dec6304abc910dea82c6f9a5904bbf365b.tar.bz2
advtrains-2dcf60dec6304abc910dea82c6f9a5904bbf365b.zip
Track can-dig check: also notify user when digging is not allowed
-rw-r--r--advtrains/locale/advtrains.de.tr1
-rw-r--r--advtrains/tracks.lua11
2 files changed, 11 insertions, 1 deletions
diff --git a/advtrains/locale/advtrains.de.tr b/advtrains/locale/advtrains.de.tr
index f0d797f..cd43eed 100644
--- a/advtrains/locale/advtrains.de.tr
+++ b/advtrains/locale/advtrains.de.tr
@@ -66,6 +66,7 @@ Subway Passenger Wagon=U-Bahn-Waggon
The wagon's inventory is not empty!=Das Inventar dieses Waggons ist nicht leer!
This track can not be changed!=Diese Schiene kann nicht geƤndert werden!
This track can not be rotated!=Diese Schiene kann nicht gedreht werden!
+This track can not be removed!=Diese Schiene kann nicht entfernt werden!
Position is occupied by a train.=Ein Zug steht an dieser Position.
There's a Track Circuit Break here.=Hier ist eine Gleisabschnittsgrenze (TCB).
There's a Signal Influence Point here.=Hier ist ein Signal-Beeinflussungspunkt.
diff --git a/advtrains/tracks.lua b/advtrains/tracks.lua
index ba59720..e034e85 100644
--- a/advtrains/tracks.lua
+++ b/advtrains/tracks.lua
@@ -442,6 +442,15 @@ Depending on the number of connections:
- conn3 <> conn4
]]
+-- Notify the user if digging the rail is not allowed
+local function can_dig_callback(pos, player)
+ local ok, reason = advtrains.can_dig_or_modify_track(pos)
+ if not ok and player then
+ minetest.chat_send_player(player:get_player_name(), attrans("This track can not be removed!") .. " " .. reason)
+ end
+ return ok
+end
+
function advtrains.register_tracks(tracktype, def, preset)
advtrains.trackplacer.register_tracktype(def.nodename_prefix, preset.tpdefault)
if preset.regtp then
@@ -478,7 +487,7 @@ function advtrains.register_tracks(tracktype, def, preset)
not_blocking_trains=1,
},
- can_dig = advtrains.can_dig_or_modify_track,
+ can_dig = can_dig_callback,
after_dig_node=function(pos)
advtrains.ndb.update(pos)
end,