diff options
Diffstat (limited to 'advtrains')
-rw-r--r-- | advtrains/signals.lua | 8 | ||||
-rw-r--r-- | advtrains/trackplacer.lua | 16 | ||||
-rw-r--r-- | advtrains/tracks.lua | 1 |
3 files changed, 14 insertions, 11 deletions
diff --git a/advtrains/signals.lua b/advtrains/signals.lua index 4dec7f5..8bdd877 100644 --- a/advtrains/signals.lua +++ b/advtrains/signals.lua @@ -3,15 +3,15 @@ local mrules_wallsignal = advtrains.meseconrules -local function can_dig_func(pos) +local function can_dig_func(pos, player) if advtrains.interlocking then - return advtrains.interlocking.signal.can_dig(pos) + return advtrains.interlocking.signal.can_dig(pos, player) end return true end -local function after_dig_func(pos) +local function after_dig_func(pos, oldnode, oldmetadata, digger) if advtrains.interlocking then - return advtrains.interlocking.signal.after_dig(pos) + return advtrains.interlocking.signal.after_dig(pos, oldnode, oldmetadata, digger) end return true end diff --git a/advtrains/trackplacer.lua b/advtrains/trackplacer.lua index 6a2c7a8..1543209 100644 --- a/advtrains/trackplacer.lua +++ b/advtrains/trackplacer.lua @@ -152,12 +152,14 @@ local function check_or_bend_rail(origin, dir, pname, commit) end end -local function track_place_node(pos, node, ndef) +local function track_place_node(pos, node, ndef, pname) --atdebug("track_place_node: ",pos, node) advtrains.ndb.swap_node(pos, node) local ndef = minetest.registered_nodes[node.name] if ndef and ndef.after_place_node then - ndef.after_place_node(pos) + -- resolve player again + local player = pname and core.get_player_by_name(pname) or nil + ndef.after_place_node(pos, player) -- note: itemstack and pointed_thing are NOT available here anymore (crap!) end end @@ -191,16 +193,16 @@ function tp.place_track(pos, tpg, pname, yaw) for k1, conn1 in ipairs(cand) do for k2, conn2 in ipairs(cand) do if k1~=k2 then - -- order of conn1/conn2: prefer conn2 being in the direction of the player facing. + -- order of conn1/conn2: prefer conn1 being in the direction of the player facing. -- the combination the other way round will be run through in a later loop iteration - if advtrains.yawToDirection(yaw, conn1, conn2) == conn2 then + if advtrains.yawToDirection(yaw, conn1, conn2) == conn1 then -- does there exist a suitable double-connection rail? --atdebug("Try double conn: ",conn1, conn2) local node = g.double[conn1.."_"..conn2] if node then check_or_bend_rail(pos, conn1, pname, true) check_or_bend_rail(pos, conn2, pname, true) - track_place_node(pos, node) -- calls after_place_node implicitly + track_place_node(pos, node, pname) -- calls after_place_node implicitly return true end end @@ -220,13 +222,13 @@ function tp.place_track(pos, tpg, pname, yaw) local node = single[conn1] if node then check_or_bend_rail(pos, conn1, pname, true) - track_place_node(pos, node) -- calls after_place_node implicitly + track_place_node(pos, node, nil, pname) -- calls after_place_node implicitly return true end end -- 4. if nothing worked, set the default local node = g.default - track_place_node(pos, node) -- calls after_place_node implicitly + track_place_node(pos, node, nil, pname) -- calls after_place_node implicitly return true end diff --git a/advtrains/tracks.lua b/advtrains/tracks.lua index 661da8a..fa7b702 100644 --- a/advtrains/tracks.lua +++ b/advtrains/tracks.lua @@ -253,6 +253,7 @@ end -- Function called when a track is about to be dug or modified by the trackworker
-- Returns either true (ok) or false,"translated string describing reason why it isn't allowed"
+-- Impl Note: possibly duplicate code in "self contained TCB" - see interlocking/tcb_ts_ui.lua!
function advtrains.can_dig_or_modify_track(pos)
if advtrains.get_train_at_pos(pos) then
return false, attrans("Position is occupied by a train.")
|