]> git.lizzy.rs Git - Crafter.git/commitdiff
Fix torches not being able to be placed over grass and snow
authoroilboi <47129783+oilboi@users.noreply.github.com>
Sun, 24 May 2020 18:56:56 +0000 (14:56 -0400)
committeroilboi <47129783+oilboi@users.noreply.github.com>
Sun, 24 May 2020 18:56:56 +0000 (14:56 -0400)
mods/torch/init.lua

index 193903cce204fb7132a3d1870bc7393b7f8d9915..675834c8562b4974b03c94b25efa1f10ead269bb 100644 (file)
@@ -98,17 +98,29 @@ minetest.register_craftitem("torch:torch", {
                        return itemstack
                end
 
-               local wdir = minetest.dir_to_wallmounted(vector.subtract(pointed_thing.under,pointed_thing.above))
+               local buildable = minetest.get_nodedef(minetest.get_node(pointed_thing.under).name, "buildable_to")
+
+               local wdir
+
+               if buildable then
+                       wdir = minetest.dir_to_wallmounted(vector.subtract(pointed_thing.under,pointed_thing.under))
+               else
+                       wdir = minetest.dir_to_wallmounted(vector.subtract(pointed_thing.under,pointed_thing.above))
+               end
 
                local fakestack = itemstack
                local retval = false
-               if wdir < 1 then
+               
+               if buildable and wdir == 4 then
+                       retval = fakestack:set_name("torch:floor")
+               elseif wdir < 1 then
                        return itemstack
                elseif wdir == 1 then
                        retval = fakestack:set_name("torch:floor")
                else
                        retval = fakestack:set_name("torch:wall")
                end
+
                if not retval then
                        return itemstack
                end