Stop rail from being placed directly above rail (floating in air)

This commit is contained in:
teknomunk 2024-04-11 14:02:53 +00:00
parent a65d043e15
commit 418efda348
1 changed files with 9 additions and 0 deletions

View File

@ -178,6 +178,15 @@ local BASE_DEF = {
_tt_help = S("Track for minecarts"),
_doc_items_usagehelp = railuse,
_doc_items_longdesc = S("Rails can be used to build transport tracks for minecarts. Normal rails slightly slow down minecarts due to friction."),
on_place = function(itemstack, placer, pointed_thing)
local node_name = minetest.get_node(pointed_thing.under).name
-- Don't allow placing rail above rail
if minetest.get_item_group(node_name,"rail") == 0 then
return minetest.item_place_node(itemstack, placer, pointed_thing)
else
return itemstack
end
end,
after_place_node = function(pos, placer, itemstack, pointed_thing)
update_rail_connections(pos)
end,