-- =================================================================== local cvt = castle.cvt local fcon = castle.fcon local modpath = castle.modpath local thisdir = modpath .. "/castle_masonry" local S = castle.S castle_masonry = {} -- =================================================================== castle_masonry.masonry_node = function (name, def) minetest.register_node (name, def) local adjname adjname = name:gsub ("^castle:", "castle_masonry:", 1) if adjname ~= name then fcon (adjname, name) end end -- =================================================================== dofile (thisdir .. "/pillars.lua" ) dofile (thisdir .. "/arrow_slits.lua" ) dofile (thisdir .. "/murder_holes.lua" ) dofile (thisdir .. "/stonewall.lua" ) dofile (thisdir .. "/paving.lua" ) -- =================================================================== local read_setting = function(name, default) local setting = minetest.setting_getbool(name) if setting == nil then return default end return setting end -- =================================================================== -- Material definition: -- { -- name=, -- the name that will be part of the resulting node names -- desc=, -- Player-facing name of the material -- tile=, -- Optional - the texture tile to use for the resulting blocks (can be a single texture or a table, as a normal node definition's tile def). If not set this will be taken from the material it's made out of. -- craft_material=, -- What source block is used to craft these blocks. -- composition_material=, -- Optional, this will override the properties of the product with a specific material. Useful if you want to use a group for the craft material (eg, "group:wood") --} -- =================================================================== castle_masonry.materials = {} if read_setting ("castle_masonry_stonewall", false) then table.insert (castle_masonry.materials, {name="stonewall", desc=S("Stonewall"), tile="castle_stonewall.png", craft_material="castle:stonewall"}) end if read_setting ("castle_masonry_cobble", false) then table.insert (castle_masonry.materials, {name="cobble", desc=S("Cobble"), tile="default_cobble.png", craft_material="default:cobble"}) end if read_setting ("castle_masonry_stonebrick", false) then table.insert (castle_masonry.materials, {name="stonebrick", desc=S("Stonebrick"), tile="default_stone_brick.png", craft_material="default:stonebrick"}) end if read_setting ("castle_masonry_sandstonebrick", false) then table.insert (castle_masonry.materials, {name="sandstonebrick", desc=S("Sandstone Brick"), tile="default_sandstone_brick.png", craft_material="default:sandstonebrick"}) end if read_setting ("castle_masonry_desertstonebrick", false) then table.insert (castle_masonry.materials, {name="desertstonebrick", desc=S("Desert Stone Brick"), tile="default_desert_stone_brick.png", craft_material="default:desert_stonebrick"}) end if read_setting ("castle_masonry_stone", false) then table.insert (castle_masonry.materials, {name="stone", desc=S("Stone"), tile="default_stone.png", craft_material="default:stone"}) end if read_setting ("castle_masonry_sandstone", false) then table.insert (castle_masonry.materials, {name="sandstone", desc=S("Sandstone"), tile="default_sandstone.png", craft_material="default:sandstone"}) end if read_setting ("castle_masonry_desertstone", false) then table.insert (castle_masonry.materials, {name="desertstone", desc=S("Desert Stone"), tile="default_desert_stone.png", craft_material="default:desert_stone"}) end if read_setting ("castle_masonry_wood", false) then table.insert (castle_masonry.materials, {name="wood", desc=S("Wood"), tile="default_wood.png", craft_material="group:wood", composition_material="default:wood"}) end if read_setting ("castle_masonry_ice", false) then table.insert (castle_masonry.materials, {name="ice", desc=S("Ice"), tile="default_ice.png", craft_material="default:ice"}) end if read_setting ("castle_masonry_snow", false) then table.insert (castle_masonry.materials, {name="snow", desc=S("Snow"), tile="default_snow.png", craft_material="default:snow"}) end if read_setting ("castle_masonry_obsidianbrick", false) then table.insert (castle_masonry.materials, {name="obsidianbrick", desc=S("Obsidian Brick"), tile="default_obsidian_brick.png", craft_material="default:obsidianbrick"}) end castle_masonry.get_material_properties = function (material) local composition_def local burn_time if material.composition_material ~= nil then composition_def = minetest.registered_nodes [material.composition_material] burn_time = minetest.get_craft_result({method="fuel", width=1, items={ItemStack(material.composition_material)}}).time else composition_def = minetest.registered_nodes [material.craft_material] burn_time = minetest.get_craft_result({method="fuel", width=1, items={ItemStack(material.craft_materia)}}).time end local tiles = material.tile if tiles == nil then tiles = composition_def.tile elseif type(tiles) == "string" then tiles = {tiles} end local desc = material.desc if desc == nil then desc = composition_def.description end return composition_def, burn_time, tiles, desc end if read_setting ("castle_masonry_pillar", false) then for _, material in pairs(castle_masonry.materials) do castle_masonry.register_pillar(material) end end if read_setting ("castle_masonry_arrowslit", false) then for _, material in pairs(castle_masonry.materials) do castle_masonry.register_arrowslit(material) end end if read_setting ("castle_masonry_murderhole", false) then for _, material in pairs(castle_masonry.materials) do castle_masonry.register_murderhole(material) end end for _, material in pairs (castle_masonry.materials) do -- Arrowslit upgrade has special handling because the castle mod arrow slit is reversed relative to current build-from-inside standard local lbm_def = { name = "castle:arrowslit_flip_front_to_back"..material.name, nodenames = { "castle:arrowslit_"..material.name, "castle:arrowslit_"..material.name.."_cross", "castle:arrowslit_"..material.name.."_hole", }, action = function(pos, node) local flip_front_to_back = {[0]=2, 3, 0, 1, 6, 7, 4, 5, 10, 7, 8, 9, 14, 15, 12, 13, 18, 19, 16, 17, 22, 23, 20, 21} node.param2 = flip_front_to_back[node.param2] node.name = "castle_masonry" .. string.sub(node.name, 7, -1) minetest.swap_node(pos, node) end } minetest.register_lbm(lbm_def) end -- =================================================================== fcon ( "castle:pillar_bottom" , "castle:pillar_stonewall_bottom" ) fcon ( "castle:pillars_bottom" , "castle:pillar_stonewall_bottom" ) fcon ( "castle_masonry:pillar_bottom" , "castle:pillar_stonewall_bottom" ) fcon ( "castle_masonry:pillars_bottom" , "castle:pillar_stonewall_bottom" ) fcon ( "castle:pillar_top" , "castle:pillar_stonewall_top" ) fcon ( "castle:pillars_top" , "castle:pillar_stonewall_top" ) fcon ( "castle_masonry:pillar_top" , "castle:pillar_stonewall_top" ) fcon ( "castle_masonry:pillars_top" , "castle:pillar_stonewall_top" ) fcon ( "castle:pillar_middle" , "castle:pillar_stonewall_middle" ) fcon ( "castle:pillars_middle" , "castle:pillar_stonewall_middle" ) fcon ( "castle_masonry:pillar_middle" , "castle:pillar_stonewall_middle" ) fcon ( "castle_masonry:pillars_middle" , "castle:pillar_stonewall_middle" ) fcon ( "castle:arrowslit" , "castle:arrowslit_stonewall" ) fcon ("castle_masonry:arrowslit" , "castle:arrowslit_stonewall" ) fcon ( "castle:arrowslit_hole" , "castle:arrowslit_stonewall_hole" ) fcon ("castle_masonry:arrowslit_hole" , "castle:arrowslit_stonewall_hole" ) fcon ( "castle:arrowslit_cross" , "castle:arrowslit_stonewall_cross" ) fcon ("castle_masonry:arrowslit_cross" , "castle:arrowslit_stonewall_cross" ) fcon ("castle:light2" , "castle:light" ) fcon ("castle:slab_stonewall_1" , "castle:slab_stonewall" ) -- =================================================================== -- End of file.