{recipeitem, recipeitem, recipeitem},
},
})
+
+ -- Flipped recipe for the silly minecrafters
+ minetest.register_craft({
+ output = 'stairs:stair_' .. subname .. ' 4',
+ recipe = {
+ {"", "", recipeitem},
+ {"", recipeitem, recipeitem},
+ {recipeitem, recipeitem, recipeitem},
+ },
+ })
end
-- Node will be called stairs:slab_<subname>
type = "fixed",
fixed = {-0.5, -0.5, -0.5, 0.5, 0, 0.5},
},
+ on_place = function(itemstack, placer, pointed_thing)
+ if pointed_thing.type ~= "node" then
+ return itemstack
+ end
+
+ -- If it's being placed on an another similar one, replace it with
+ -- a full block
+ local slabpos = nil
+ local slabnode = nil
+ local p0 = pointed_thing.under
+ local p1 = pointed_thing.above
+ local n0 = minetest.env:get_node(p0)
+ local n1 = minetest.env:get_node(p1)
+ if n0.name == "stairs:slab_" .. subname then
+ slabpos = p0
+ slabnode = n0
+ elseif n1.name == "stairs:slab_" .. subname then
+ slabpos = p1
+ slabnode = n1
+ end
+ if slabpos then
+ -- Remove the slab at slabpos
+ minetest.env:remove_node(slabpos)
+ -- Make a fake stack of a single item and try to place it
+ local fakestack = ItemStack(recipeitem)
+ pointed_thing.above = slabpos
+ fakestack = minetest.item_place(fakestack, placer, pointed_thing)
+ -- If the item was taken from the fake stack, decrement original
+ if not fakestack or fakestack:is_empty() then
+ itemstack:take_item(1)
+ -- Else put old node back
+ else
+ minetest.env:set_node(slabpos, slabnode)
+ end
+ return itemstack
+ end
+
+ -- Otherwise place regularly
+ return minetest.item_place(itemstack, placer, pointed_thing)
+ end,
})
minetest.register_craft({