diff options
author | 1F616EMO <root@1f616emo.xyz> | 2024-09-08 08:57:32 +0800 |
---|---|---|
committer | orwell <orwell@bleipb.de> | 2024-11-09 22:05:46 +0100 |
commit | 671cb16e9599f9989cf5b12f76f1eb0a21252172 (patch) | |
tree | 0e6802dfab5859cfe7a32ee5b8e55b2334496a91 /advtrains/trackplacer.lua | |
parent | 63f81cb2043de58f0b1be9d0688368572807b742 (diff) | |
download | advtrains-671cb16e9599f9989cf5b12f76f1eb0a21252172.tar.gz advtrains-671cb16e9599f9989cf5b12f76f1eb0a21252172.tar.bz2 advtrains-671cb16e9599f9989cf5b12f76f1eb0a21252172.zip |
Allow operate on_rightclick nodes with track placers and wagon placers
Press sneak to force default behavior.
Diffstat (limited to 'advtrains/trackplacer.lua')
-rw-r--r-- | advtrains/trackplacer.lua | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/advtrains/trackplacer.lua b/advtrains/trackplacer.lua index 9f97171..2588088 100644 --- a/advtrains/trackplacer.lua +++ b/advtrains/trackplacer.lua @@ -275,11 +275,24 @@ function tp.register_track_placer(nnprefix, imgprefix, dispname, def) groups={advtrains_trackplacer=1, digtron_on_place=1}, liquids_pointable = def.liquids_pointable, on_place = function(itemstack, placer, pointed_thing) - local name = placer:get_player_name() - if not name then - return itemstack, false - end if pointed_thing.type=="node" then + do + local pointed_pos = pointed_thing.under + local pointed_node = minetest.get_node(pointed_pos) + local pointed_def = minetest.registered_nodes[pointed_node.name] + if pointed_def and pointed_def.on_rightclick then + local controls = placer:get_player_control() + if not controls.sneak then + return pointed_def.on_rightclick(pointed_pos, pointed_node, placer, itemstack, pointed_thing) + end + end + end + + local name = placer:get_player_name() + if not name then + return itemstack, false + end + local pos=pointed_thing.above local upos=vector.subtract(pointed_thing.above, {x=0, y=1, z=0}) if not advtrains.check_track_protection(pos, name) then |