aboutsummaryrefslogtreecommitdiff
path: root/advtrains/tracks.lua
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 /advtrains/tracks.lua
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
Diffstat (limited to 'advtrains/tracks.lua')
-rw-r--r--advtrains/tracks.lua11
1 files changed, 10 insertions, 1 deletions
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,