Code: Select all
c_doors = {}
-- Register Door Nodes
c_doors.door = {
{"steel", "Steel", {cracky = 1, door =1}, default.node_sound_metal_defaults(), "c_doors_metal", {name = "doors_door_steel.png",backface_culling = true}, "default:steelblock"},
{"obsidian_glass", "Obsidian Glass", {cracky = 1, door =1}, default.node_sound_glass_defaults(), "c_doors_glass", {name = "doors_door_obsidian_glass.png"},"default:obsidian_glass"},
{"glass", "Glass", {cracky = 3, door =1}, default.node_sound_glass_defaults(), "c_doors_glass", {name = "doors_door_glass.png"}, "default:glass"},
{"wood", "Wood", {choppy = 2, door =1}, default.node_sound_wood_defaults(), "doors_door", {name = "doors_door_wood.png",backface_culling = true}, "default:wood"},
}
for _, row in ipairs(c_doors.door) do
local name = row[1]
local desc = row[2]
local mat_groups = row[3]
local mat_sound = row[4]
local door_sound = row[5]
local door_tiles = row[6]
local craft_material = row[7]
minetest.register_node("c_doors:" ..name.. "_Ldoor", {
description = desc.. " Door (left)",
inventory_image = "doors_item_" ..name.. ".png",
wield_image = "doors_item_" ..name.. ".png",
drawtype = "mesh",
mesh = "c_door_L.obj",
tiles = {door_tiles},
use_texture_alpha = true,
paramtype = "light",
paramtype2 = "facedir",
on_rotate = screwdriver.rotate_simple,
sunlight_propogates = true,
is_ground_content = false,
groups = mat_groups,
sounds = mat_sound,
selection_box = {
type = "fixed",
fixed = {
{-0.5, -0.5, -0.0625, 0.5, 1.5, 0.0625},
},
},
collision_box = {
type = "fixed",
fixed = {
{-0.5, -0.5, -0.0625, 0.5, 1.5, 0.0625},
},
},
on_rightclick = function(pos, node, puncher)
minetest.swap_node(pos, {name = "c_doors:" ..name.. "_Ldoor_open", param2 = node.param2})
minetest.sound_play(door_sound.."_open", {gain = 0.20, max_hear_distance = 2})
end,
})
minetest.register_node("c_doors:" ..name.. "_Ldoor_open", {
drawtype = "mesh",
mesh = "c_door_L_open.obj",
tiles = {door_tiles},
use_texture_alpha = true,
paramtype = "light",
paramtype2 = "facedir",
on_rotate = screwdriver.rotate_simple,
legacy_facedir_simple = true,
sunlight_propogates = true,
is_ground_content = false,
groups = mat_groups,
drop = "c_doors:" ..name.. "_Ldoor",
sounds = mat_sound,
selection_box = {
type = "fixed",
fixed = {
{-0.5, -0.5, -0.9375, -0.375, 1.5, 0.0625},
},
},
collision_box = {
type = "fixed",
fixed = {
{-0.5, -0.5, -0.9375, -0.375, 1.5, 0.0625},
},
},
on_rightclick = function(pos, node, puncher)
minetest.swap_node(pos, {name = "c_doors:" ..name.. "_Ldoor", param2 = node.param2})
minetest.sound_play(door_sound.."_close", {gain = 0.15, max_hear_distance = 2})
end,
})
minetest.register_node("c_doors:" ..name.. "_Rdoor", {
description = desc.. " Door (right)",
inventory_image = "doors_item_" ..name.. ".png",
wield_image = "doors_item_" ..name.. ".png",
drawtype = "mesh",
mesh = "c_door_R.obj",
tiles = {door_tiles},
use_texture_alpha = true,
paramtype = "light",
paramtype2 = "facedir",
on_rotate = screwdriver.rotate_simple,
sunlight_propogates = true,
is_ground_content = false,
groups = mat_groups,
sounds = mat_sound,
selection_box = {
type = "fixed",
fixed = {
{-0.5, -0.5, -0.0625, 0.5, 1.5, 0.0625},
},
},
collision_box = {
type = "fixed",
fixed = {
{-0.5, -0.5, -0.0625, 0.5, 1.5, 0.0625},
},
},
on_rightclick = function(pos, node, puncher)
minetest.swap_node(pos, {name = "c_doors:" ..name.. "_Rdoor_open", param2 = node.param2})
minetest.sound_play(door_sound.."_open", {gain = 0.20, max_hear_distance = 2})
end,
})
minetest.register_node("c_doors:" ..name.. "_Rdoor_open", {
drawtype = "mesh",
mesh = "c_door_R_open.obj",
tiles = {door_tiles},
use_texture_alpha = true,
paramtype = "light",
paramtype2 = "facedir",
on_rotate = screwdriver.rotate_simple,
legacy_facedir_simple = true,
sunlight_propogates = true,
is_ground_content = false,
groups = mat_groups,
drop = "c_doors:" ..name.. "_Rdoor",
sounds = mat_sound,
selection_box = {
type = "fixed",
fixed = {
{0.375, -0.5, -0.9375, 0.5, 1.5, 0.0625},
},
},
collision_box = {
type = "fixed",
fixed = {
{0.375, -0.5, -0.9375, 0.5, 1.5, 0.0625},
},
},
on_rightclick = function(pos, node, puncher)
minetest.swap_node(pos, {name = "c_doors:" ..name.. "_Rdoor", param2 = node.param2})
minetest.sound_play(door_sound.."_close", {gain = 0.15, max_hear_distance = 2})
end,
})
--
-- Crafting
--
minetest.register_craft({
output = "c_doors:" ..name.. "_Ldoor",
recipe = {
{"", craft_material , ""},
{"", craft_material, ""},
{"", craft_material , ""},
}
})
minetest.register_craft({
output = "c_doors:" ..name.. "_Rdoor",
recipe = {
{"c_doors:" ..name.. "_Ldoor"},
}
})
minetest.register_craft({
output = "c_doors:" ..name.. "_Ldoor",
recipe = {
{"c_doors:" ..name.. "_Rdoor"},
}
})
end
Now I can finally push these changes to my repo.
Thank you stu and paramat for taking the time to help, it is very much appreciated.