--[[ More Blocks: node definitions Copyright (c) 2011-2017 Hugo Locurcio and contributors. 2018-2020 Och_Noe Licensed under the zlib license. See LICENSE.md for more information. --]] local S = moreblocks.intllib local sound_dirt = default.node_sound_dirt_defaults() local sound_wood = default.node_sound_wood_defaults() local sound_stone = default.node_sound_stone_defaults() local sound_glass = default.node_sound_glass_defaults() local sound_leaves = default.node_sound_leaves_defaults() local sound_gravel = default.node_sound_gravel_defaults() -- Don't break on 0.4.14 and earlier. local sound_metal = (default.node_sound_metal_defaults and default.node_sound_metal_defaults() or sound_stone) local function tile_tiles(name) local tex = "moreblocks_" ..name.. ".png" return {tex, tex, tex, tex, tex.. "^[transformR90", tex.. "^[transformR90"} end local box_slope = { type = "fixed", fixed = { {-0.5, -0.5, -0.5, 0.5, -0.25, 0.5}, {-0.5, -0.25, -0.25, 0.5, 0, 0.5}, {-0.5, 0, 0, 0.5, 0.25, 0.5}, {-0.5, 0.25, 0.25, 0.5, 0.5, 0.5} } } local box_slope_half = { type = "fixed", fixed = { {-0.5, -0.5, -0.5, 0.5, -0.375, 0.5}, {-0.5, -0.375, -0.25, 0.5, -0.25, 0.5}, {-0.5, -0.25, 0, 0.5, -0.125, 0.5}, {-0.5, -0.125, 0.25, 0.5, 0, 0.5}, } } local box_slope_half_raised = { type = "fixed", fixed = { {-0.5, -0.5, -0.5, 0.5, 0.125, 0.5}, {-0.5, 0.125, -0.25, 0.5, 0.25, 0.5}, {-0.5, 0.25, 0, 0.5, 0.375, 0.5}, {-0.5, 0.375, 0.25, 0.5, 0.5, 0.5}, } } local box_slope_third = { type = "fixed", fixed = { {-0.5, -0.5, -0.5, 0.5, -0.417 , 0.5}, {-0.5, -0.417, -0.25, 0.5, -0.333 , 0.5}, {-0.5, -0.333, 0, 0.5, -0.250 , 0.5}, {-0.5, -0.250, 0.25, 0.5, -0.167, 0.5}, } } local box_slope_third_raised = { type = "fixed", fixed = { {-0.5, -0.5, -0.5, 0.5, -0.083 , 0.5}, {-0.5, -0.083, -0.25, 0.5, 0 , 0.5}, {-0.5, 0 , 0, 0.5, 0.083 , 0.5}, {-0.5, 0.083, 0.25, 0.5, 0.167, 0.5}, } } local box_slope_third_top = { type = "fixed", fixed = { {-0.5, -0.5, -0.5, 0.5, 0.250, 0.5}, {-0.5, 0.250, -0.25, 0.5, 0.333, 0.5}, {-0.5, 0.333, 0, 0.5, 0.417, 0.5}, {-0.5, 0.417, 0.25, 0.5, 0.5 , 0.5}, } } local minimal_slopes_defs = { [""] = { mesh = "moreblocks_slope.obj", collision_box = box_slope, selection_box = box_slope, }, ["_half"] = { mesh = "moreblocks_slope_half.obj", collision_box = box_slope_half, selection_box = box_slope_half, }, ["_half_raised"] = { mesh = "moreblocks_slope_half_raised.obj", collision_box = box_slope_half_raised, selection_box = box_slope_half_raised, }, } local function copytable(orig) local orig_type = type(orig) local copy if orig_type == 'table' then copy = {} for orig_key, orig_value in next, orig, nil do copy[copytable(orig_key)] = copytable(orig_value) end setmetatable(copy, copytable(getmetatable(orig))) else copy = orig end return copy end local function register_minimal_shapes(modname, subname, recipeitem, fields) local defs = copytable(minimal_slopes_defs) local desc = S("%s Slope"):format(fields.description) for alternate, def in pairs(defs) do for k, v in pairs(fields) do def[k] = v end def.drawtype = "mesh" def.paramtype = "light" def.paramtype2 = def.paramtype2 or "facedir" def.on_place = minetest.rotate_node def.description = desc def.use_texture_alpha = fields.use_texture_alpha def.groups = def.groups -- stairsplus:prepare_groups(fields.groups) if fields.drop and not (type(fields.drop) == "table") then def.drop = modname.. ":slope_" ..fields.drop..alternate end minetest.register_node(":" ..modname.. ":slope_" ..subname..alternate, def) end minetest.register_craft({ recipe = { { "","","" }, { "","",recipeitem, }, { "", recipeitem, recipeitem }, }, output = modname .. ":slope_" .. subname }) minetest.register_craft({ recipe = { { "","","" }, { "","","", }, { "", recipeitem, recipeitem }, }, output = modname .. ":slope_" .. subname .. "_half 12" }) minetest.register_craft({ recipe = { { "","",recipeitem, }, { "","","" }, { "", recipeitem, recipeitem }, }, output = modname .. ":slope_" .. subname .. "_half_raised 4" }) minetest.register_craft({ type = "shapeless", output = recipeitem, recipe = {modname .. ":slope_" .. subname, modname .. ":slope_" .. subname}, }) minetest.register_craft({ type = "shapeless", output = recipeitem, recipe = {modname .. ":slope_" .. subname .. "_half", modname .. ":slope_" .. subname .. "_half_raised"}, }) -- 100% slope 1 node -- 50% slope 2 nodes -- 50% slab 1 node end local nodes = { ["wood_tile"] = { description = S("Wooden Tile"), groups = {snappy = 1, choppy = 2, oddly_breakable_by_hand = 2, flammable = 3}, tiles = {"default_wood.png^moreblocks_wood_tile.png", "default_wood.png^moreblocks_wood_tile.png", "default_wood.png^moreblocks_wood_tile.png", "default_wood.png^moreblocks_wood_tile.png", "default_wood.png^moreblocks_wood_tile.png^[transformR90", "default_wood.png^moreblocks_wood_tile.png^[transformR90"}, sounds = sound_wood, }, ["wood_tile_flipped"] = { description = S("Wooden Tile"), groups = {wood = 1, snappy = 1, choppy = 2, oddly_breakable_by_hand = 2, flammable = 3}, tiles = {"default_wood.png^moreblocks_wood_tile.png^[transformR90", "default_wood.png^moreblocks_wood_tile.png^[transformR90", "default_wood.png^moreblocks_wood_tile.png^[transformR90", "default_wood.png^moreblocks_wood_tile.png^[transformR90", "default_wood.png^moreblocks_wood_tile.png^[transformR180", "default_wood.png^moreblocks_wood_tile.png^[transformR180"}, sounds = sound_wood, no_stairs = true, }, ["wood_tile_center"] = { description = S("Centered Wooden Tile"), groups = {wood = 1, snappy = 1, choppy = 2, oddly_breakable_by_hand = 2, flammable = 3}, tiles = {"default_wood.png^moreblocks_wood_tile_center.png"}, sounds = sound_wood, }, ["wood_tile_full"] = { description = S("Full Wooden Tile"), groups = {wood = 1, snappy = 1, choppy = 2, oddly_breakable_by_hand = 2, flammable = 3}, tiles = tile_tiles("wood_tile_full"), sounds = sound_wood, }, ["wood_tile_up"] = { description = S("Upwards Wooden Tile"), groups = {wood = 1, snappy = 1, choppy = 2, oddly_breakable_by_hand = 2, flammable = 3}, tiles = {"default_wood.png^moreblocks_wood_tile_up.png"}, sounds = sound_wood, no_stairs = true, }, ["wood_tile_down"] = { description = S("Downwards Wooden Tile"), groups = {wood = 1, snappy = 1, choppy = 2, oddly_breakable_by_hand = 2, flammable = 3}, tiles = {"default_wood.png^[transformR180^moreblocks_wood_tile_up.png^[transformR180"}, sounds = sound_wood, no_stairs = true, }, ["wood_tile_left"] = { description = S("Leftwards Wooden Tile"), groups = {wood = 1, snappy = 1, choppy = 2, oddly_breakable_by_hand = 2, flammable = 3}, tiles = {"default_wood.png^[transformR270^moreblocks_wood_tile_up.png^[transformR270"}, sounds = sound_wood, no_stairs = true, }, ["wood_tile_right"] = { description = S("Rightwards Wooden Tile"), groups = {wood = 1, snappy = 1, choppy = 2, oddly_breakable_by_hand = 2, flammable = 3}, tiles = {"default_wood.png^[transformR90^moreblocks_wood_tile_up.png^[transformR90"}, sounds = sound_wood, no_stairs = true, }, ["circle_stone_bricks"] = { description = S("Circle Stone Bricks"), groups = {cracky = 3}, sounds = sound_stone, }, ["grey_bricks"] = { description = S("Stone Bricks"), groups = {cracky = 3}, sounds = sound_stone, }, ["coal_stone_bricks"] = { description = S("Coal Stone Bricks"), groups = {cracky = 3}, sounds = sound_stone, }, ["iron_stone_bricks"] = { description = S("Iron Stone Bricks"), groups = {cracky = 3}, sounds = sound_stone, }, ["stone_tile"] = { description = S("Stone Tile"), groups = {cracky = 3}, sounds = sound_stone, }, ["split_stone_tile"] = { description = S("Split Stone Tile"), tiles = {"moreblocks_split_stone_tile_top std::time_t timestamp = std::time(0); };