diff options
author | orwell96 <orwell@bleipb.de> | 2021-03-12 17:30:50 +0100 |
---|---|---|
committer | orwell96 <orwell@bleipb.de> | 2021-03-12 17:30:50 +0100 |
commit | 2dcf60dec6304abc910dea82c6f9a5904bbf365b (patch) | |
tree | b534822e5f0d220b6d344b21719fc954ffdeec46 /advtrains/tracks.lua | |
parent | 0c7beca20e5f97a2ef24334282d7615d92295ad0 (diff) | |
download | advtrains-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.lua | 11 |
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, |