From d91da8b442bb4e427bac360ebe301eff6e32d96d Mon Sep 17 00:00:00 2001 From: Foz Date: Thu, 21 Dec 2017 14:02:01 -0500 Subject: [PATCH] Fix slab descriptions. A regression caused the description of slabs to revert to the source block's description. This commit fixes the regression and adds descriptions which were missing for the recently added slabs (two_sides, three_sides, and three_sides_u). Closes minetest-mods/moreblocks#96 --- stairsplus/slabs.lua | 35 +++++++++++++++-------------------- 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/stairsplus/slabs.lua b/stairsplus/slabs.lua index 6135d3b..de7f031 100644 --- a/stairsplus/slabs.lua +++ b/stairsplus/slabs.lua @@ -66,30 +66,25 @@ function stairsplus:register_slab(modname, subname, recipeitem, fields) local defs = stairsplus.copytable(slabs_defs) local desc_base = S("%s Slab"):format(fields.description) for alternate, shape in pairs(defs) do - local def = {} - - if type(shape) ~= "table" then - def = { - node_box = { - type = "fixed", - fixed = {-0.5, -0.5, -0.5, 0.5, (shape/16)-0.5, 0.5}, - }, - description = ("%s (%d/16)"):format(desc_base, shape) - } - else - def = { - node_box = { - type = "fixed", - fixed = shape, - }, - description = desc_base - } - end - for k, v in pairs(fields) do def[k] = v end + if type(shape) ~= "table" then + def.node_box = { + type = "fixed", + fixed = {-0.5, -0.5, -0.5, 0.5, (shape/16)-0.5, 0.5}, + } + def.description = ("%s (%d/16)"):format(desc_base, shape) + else + def.node_box = { + type = "fixed", + fixed = shape, + } + local desc_x = alternate:gsub("_", " ") + desc_x = desc_x:gsub("(%a)(%S*)", function(a, b) return a:upper() .. b end) + def.description = desc_base .. desc_x + end def.drawtype = "nodebox" def.paramtype = "light"