Stairs: Add backface culling to stair meshes
authorJohannes Fritz <Mr.rar1998@gmail.com>
Wed, 7 Jun 2017 16:42:44 +0000 (11:42 -0500)
committerparamat <mat.gregory@virginmedia.com>
Sat, 1 Jul 2017 03:22:11 +0000 (04:22 +0100)
If backface culling is not specified for a tile in 'images' it is set to true.
Slabs already have backface culling due to being defined as nodeboxes (which
are then converted to meshnodes).

mods/stairs/init.lua

index 4f8e064cf7e3fc75ab6bfcf379873b03a7f86bf2..787c04e04928142f266cdca85223bed326a7d4ef 100644 (file)
@@ -46,12 +46,24 @@ end
 -- Node will be called stairs:stair_<subname>
 
 function stairs.register_stair(subname, recipeitem, groups, images, description, sounds)
+       local stair_images = {}
+       for i, image in ipairs(images) do
+               if type(image) == "string" then
+                       stair_images[i] = {
+                               name = image,
+                               backface_culling = true,
+                       }
+               elseif image.backface_culling == nil then -- override using any other value
+                       stair_images[i] = table.copy(image)
+                       stair_images[i].backface_culling = true
+               end
+       end
        groups.stair = 1
        minetest.register_node(":stairs:stair_" .. subname, {
                description = description,
                drawtype = "mesh",
                mesh = "stairs_stair.obj",
-               tiles = images,
+               tiles = stair_images,
                paramtype = "light",
                paramtype2 = "facedir",
                is_ground_content = false,