Allow building doors on buildable_to nodes.
authorAuke Kok <sofar@foo-projects.org>
Sun, 14 Feb 2016 04:00:37 +0000 (20:00 -0800)
committerparamat <mat.gregory@virginmedia.com>
Fri, 19 Feb 2016 19:54:50 +0000 (19:54 +0000)
This code never allowed placing a door on e.g. a grass
plant. The code to handle this isn't that complex. With
this code, doors can be placed on flowers and on normal
node surfaces without issues.

mods/doors/init.lua

index 925c94e88fdef8322901e3e613a5e04a5ce9c380..b1a04cc7b8c1631f840f8003ffc295eab59eff4b 100644 (file)
@@ -183,8 +183,15 @@ function doors.register(name, def)
                inventory_image = def.inventory_image,
 
                on_place = function(itemstack, placer, pointed_thing)
-                       local pos = pointed_thing.above
-                       local node = minetest.get_node(pos)
+                       local pos = nil
+
+                       local node = minetest.get_node(pointed_thing.under)
+                       if minetest.registered_nodes[node.name].buildable_to then
+                               pos = pointed_thing.under
+                       else
+                               pos = pointed_thing.above
+                               node = minetest.get_node(pos)
+                       end
 
                        if not minetest.registered_nodes[node.name].buildable_to then
                                return itemstack