forked from VoxeLibre/VoxeLibre
Improve the code
This commit is contained in:
parent
70eb019a58
commit
9c208fb6b0
|
@ -54,19 +54,11 @@ function mcl_doors:register_door(name, def)
|
||||||
def.sound_close = "doors_door_close"
|
def.sound_close = "doors_door_close"
|
||||||
end
|
end
|
||||||
|
|
||||||
local box = {{-8/16, -8/16, -8/16, 8/16, 8/16, -5/16}}
|
if not def.node_box then
|
||||||
|
def.node_box = {{-8/16, -8/16, -8/16, 8/16, 8/16, -5/16}}
|
||||||
if not def.node_box_bottom then
|
|
||||||
def.node_box_bottom = box
|
|
||||||
end
|
end
|
||||||
if not def.node_box_top then
|
if not def.selection_box then
|
||||||
def.node_box_top = box
|
def.selection_box = {{-8/16, -8/16, -8/16, 8/16, 8/16, -5/16}}
|
||||||
end
|
|
||||||
if not def.selection_box_bottom then
|
|
||||||
def.selection_box_bottom= box
|
|
||||||
end
|
|
||||||
if not def.selection_box_top then
|
|
||||||
def.selection_box_top = box
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local longdesc, usagehelp, tt_help
|
local longdesc, usagehelp, tt_help
|
||||||
|
@ -202,22 +194,22 @@ function mcl_doors:register_door(name, def)
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
local doortextop = def.tiles_top:match("(.+)%..+$")
|
local top_door_texture = def.tiles_top:match("(.+)%..+$") -- This removes the filename extension from the images.
|
||||||
local doortexbottom = def.tiles_bottom:match("(.+)%..+$")
|
local bottom_door_texture = def.tiles_bottom:match("(.+)%..+$") -- This removes the filename extension from the images.
|
||||||
|
|
||||||
local tt = doortextop .. ".png"
|
local texture_top = top_door_texture .. ".png"
|
||||||
local tb = doortexbottom .. ".png"
|
local texture_bottom = bottom_door_texture .. ".png"
|
||||||
local ttt = doortextop .. "_toppart.png" -- Special texture to make the top of opened doors not look weird.
|
local texture_top_toppart = top_door_texture .. "_toppart.png" -- Special texture to make the top of opened doors not look weird.
|
||||||
local tbb = doortexbottom .. "_bottompart.png" -- Special texture to make the bottom of opened doors not look weird.
|
local texture_bottom_bottompart = bottom_door_texture .. "_bottompart.png" -- Special texture to make the bottom of opened doors not look weird.
|
||||||
local tts = doortextop .. "_side.png" -- Special texture to make the side of opened doors not look weird.
|
local texture_top_side = top_door_texture .. "_side.png" -- Special texture to make the side of opened doors not look weird.
|
||||||
local tbs = doortexbottom .. "_side.png" -- Special texture to make the side of opened doors not look weird.
|
local texture_bottom_side = bottom_door_texture .. "_side.png" -- Special texture to make the side of opened doors not look weird.
|
||||||
|
|
||||||
local ttm = tt .. "^[transformFX"
|
local texture_top_mirrored = texture_top .. "^[transformFX"
|
||||||
local tbm = tb .. "^[transformFX"
|
local texture_bottom_mirrored = texture_bottom .. "^[transformFX"
|
||||||
local tttm = ttt .. "^[transformFX"
|
local texture_top_toppart_mirrored = texture_top_toppart .. "^[transformFX"
|
||||||
local tbbm = tbb .. "^[transformFX"
|
local texture_bottom_bottompart_mirrored = texture_bottom_bottompart .. "^[transformFX"
|
||||||
local ttsm = tts .. "^[transformFX"
|
local texture_top_side_mirrored = texture_top_side .. "^[transformFX"
|
||||||
local tbsm = tbs .. "^[transformFX"
|
local texture_bottom_side_mirrored = texture_bottom_side .. "^[transformFX"
|
||||||
|
|
||||||
local function on_open_close(pos, dir, check_name, replace, replace_dir)
|
local function on_open_close(pos, dir, check_name, replace, replace_dir)
|
||||||
local meta1 = minetest_get_meta(pos)
|
local meta1 = minetest_get_meta(pos)
|
||||||
|
@ -304,8 +296,8 @@ function mcl_doors:register_door(name, def)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_node(name.."_b_1", {
|
local template_def = {
|
||||||
tiles = {"blank.png", tbb .. "^[transformFY", tbs, tbsm, tbm, tb},
|
tiles = nil,
|
||||||
use_texture_alpha = minetest.features.use_texture_alpha_string_modes and "clip" or true,
|
use_texture_alpha = minetest.features.use_texture_alpha_string_modes and "clip" or true,
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
paramtype2 = "facedir",
|
paramtype2 = "facedir",
|
||||||
|
@ -315,56 +307,65 @@ function mcl_doors:register_door(name, def)
|
||||||
drawtype = "nodebox",
|
drawtype = "nodebox",
|
||||||
node_box = {
|
node_box = {
|
||||||
type = "fixed",
|
type = "fixed",
|
||||||
fixed = def.node_box_bottom
|
fixed = def.node_box
|
||||||
},
|
},
|
||||||
selection_box = {
|
selection_box = {
|
||||||
type = "fixed",
|
type = "fixed",
|
||||||
fixed = def.selection_box_bottom
|
fixed = def.selection_box
|
||||||
},
|
},
|
||||||
groups = def.groups,
|
groups = def.groups,
|
||||||
_mcl_hardness = def._mcl_hardness,
|
_mcl_hardness = def._mcl_hardness,
|
||||||
_mcl_blast_resistance = def._mcl_blast_resistance,
|
_mcl_blast_resistance = def._mcl_blast_resistance,
|
||||||
sounds = def.sounds,
|
sounds = def.sounds,
|
||||||
|
|
||||||
after_destruct = function(bottom, oldnode)
|
after_destruct = nil,
|
||||||
local meta_bottom = minetest_get_meta(bottom)
|
|
||||||
if meta_bottom:get_int("rotation") == 1 then
|
|
||||||
meta_bottom:set_int("rotation", 0)
|
|
||||||
else
|
|
||||||
minetest.add_item(bottom, name)
|
|
||||||
local top = { x = bottom.x, y = bottom.y + 1, z = bottom.z }
|
|
||||||
if minetest.get_node(bottom).name ~= name.."_b_2" and minetest.get_node(top).name == name.."_t_1" then
|
|
||||||
minetest.remove_node(top)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
|
|
||||||
on_rightclick = on_rightclick,
|
on_rightclick = nil,
|
||||||
|
|
||||||
mesecons = { effector = {
|
mesecons = nil,
|
||||||
action_on = on_mesecons_signal_open,
|
|
||||||
}},
|
|
||||||
|
|
||||||
on_rotate = function(bottom, node, user, mode, param2)
|
on_rotate = nil,
|
||||||
if mode == screwdriver.ROTATE_FACE then
|
|
||||||
local meta_bottom = minetest_get_meta(bottom)
|
|
||||||
meta_bottom:set_int("rotation", 1)
|
|
||||||
node.param2 = screwdriver.rotate.facedir(bottom, node, mode)
|
|
||||||
minetest.swap_node(bottom, node)
|
|
||||||
|
|
||||||
local top = {x=bottom.x,y=bottom.y+1,z=bottom.z}
|
|
||||||
local meta_top = minetest_get_meta(top)
|
|
||||||
meta_top:set_int("rotation", 1)
|
|
||||||
node.name = name .."_t_1"
|
|
||||||
minetest.swap_node(top, node)
|
|
||||||
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
return false
|
|
||||||
end,
|
|
||||||
|
|
||||||
can_dig = check_player_priv,
|
can_dig = check_player_priv,
|
||||||
})
|
}
|
||||||
|
|
||||||
|
local _b_1_def = table.copy(template_def)
|
||||||
|
_b_1_def.tiles = {"blank.png", texture_bottom_bottompart .. "^[transformFY", texture_bottom_side, texture_bottom_side_mirrored, texture_bottom_mirrored, texture_bottom}
|
||||||
|
_b_1_def.after_destruct = function(bottom, oldnode)
|
||||||
|
local meta_bottom = minetest_get_meta(bottom)
|
||||||
|
if meta_bottom:get_int("rotation") == 1 then
|
||||||
|
meta_bottom:set_int("rotation", 0)
|
||||||
|
else
|
||||||
|
minetest.add_item(bottom, name)
|
||||||
|
local top = { x = bottom.x, y = bottom.y + 1, z = bottom.z }
|
||||||
|
if minetest.get_node(bottom).name ~= name.."_b_2" and minetest.get_node(top).name == name.."_t_1" then
|
||||||
|
minetest.remove_node(top)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
_b_1_def.on_rightclick = on_rightclick
|
||||||
|
_b_1_def.mesecons = { effector = {
|
||||||
|
action_on = on_mesecons_signal_open,
|
||||||
|
}}
|
||||||
|
_b_1_def.on_rotate = function(bottom, node, user, mode, param2)
|
||||||
|
if mode == screwdriver.ROTATE_FACE then
|
||||||
|
local meta_bottom = minetest_get_meta(bottom)
|
||||||
|
meta_bottom:set_int("rotation", 1)
|
||||||
|
node.param2 = screwdriver.rotate.facedir(bottom, node, mode)
|
||||||
|
minetest.swap_node(bottom, node)
|
||||||
|
|
||||||
|
local top = {x=bottom.x,y=bottom.y+1,z=bottom.z}
|
||||||
|
local meta_top = minetest_get_meta(top)
|
||||||
|
meta_top:set_int("rotation", 1)
|
||||||
|
node.name = name .."_t_1"
|
||||||
|
minetest.swap_node(top, node)
|
||||||
|
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
minetest.register_node(name.."_b_1", _b_1_def)
|
||||||
|
|
||||||
if def.only_redstone_can_open then
|
if def.only_redstone_can_open then
|
||||||
on_rightclick = nil
|
on_rightclick = nil
|
||||||
|
@ -376,67 +377,43 @@ function mcl_doors:register_door(name, def)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_node(name.."_t_1", {
|
local _t_1_def = table.copy(template_def)
|
||||||
tiles = {ttt .. "^[transformFY", "blank.png", tts, ttsm, ttm, tt},
|
_t_1_def.tiles = {texture_top_toppart .. "^[transformFY", "blank.png", texture_top_side, texture_top_side_mirrored, texture_top_mirrored, texture_top}
|
||||||
use_texture_alpha = minetest.features.use_texture_alpha_string_modes and "clip" or true,
|
_t_1_def.after_destruct = function(top, oldnode)
|
||||||
paramtype = "light",
|
local meta_top = minetest_get_meta(top)
|
||||||
paramtype2 = "facedir",
|
if meta_top:get_int("rotation") == 1 then
|
||||||
sunlight_propagates = true,
|
meta_top:set_int("rotation", 0)
|
||||||
is_ground_content = false,
|
else
|
||||||
drop = "",
|
local bottom = { x = top.x, y = top.y - 1, z = top.z }
|
||||||
drawtype = "nodebox",
|
if minetest.get_node(top).name ~= name.."_t_2" and minetest.get_node(bottom).name == name.."_b_1" and oldnode.name == name.."_t_1" then
|
||||||
node_box = {
|
minetest.dig_node(bottom)
|
||||||
type = "fixed",
|
end
|
||||||
fixed = def.node_box_top
|
end
|
||||||
},
|
end
|
||||||
selection_box = {
|
_t_1_def.on_rightclick = on_rightclick
|
||||||
type = "fixed",
|
_t_1_def.mesecons = { effector = {
|
||||||
fixed = def.selection_box_top
|
action_on = on_mesecons_signal_open_top,
|
||||||
},
|
rules = mesecon.rules.flat,
|
||||||
groups = def.groups,
|
}}
|
||||||
_mcl_hardness = def._mcl_hardness,
|
_t_1_def.on_rotate = function(top, node, user, mode, param2)
|
||||||
_mcl_blast_resistance = def._mcl_blast_resistance,
|
if mode == screwdriver.ROTATE_FACE then
|
||||||
sounds = def.sounds,
|
|
||||||
|
|
||||||
after_destruct = function(top, oldnode)
|
|
||||||
local meta_top = minetest_get_meta(top)
|
local meta_top = minetest_get_meta(top)
|
||||||
if meta_top:get_int("rotation") == 1 then
|
meta_top:set_int("rotation", 1)
|
||||||
meta_top:set_int("rotation", 0)
|
node.param2 = screwdriver.rotate.facedir(top, node, mode)
|
||||||
else
|
minetest.swap_node(top, node)
|
||||||
local bottom = { x = top.x, y = top.y - 1, z = top.z }
|
|
||||||
if minetest.get_node(top).name ~= name.."_t_2" and minetest.get_node(bottom).name == name.."_b_1" and oldnode.name == name.."_t_1" then
|
|
||||||
minetest.dig_node(bottom)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
|
|
||||||
on_rightclick = on_rightclick,
|
local bottom = {x=top.x,y=top.y-1,z=top.z}
|
||||||
|
local meta_bottom = minetest_get_meta(bottom)
|
||||||
|
meta_bottom:set_int("rotation", 1)
|
||||||
|
node.name = name .."_b_1"
|
||||||
|
minetest.swap_node(bottom, node)
|
||||||
|
|
||||||
mesecons = { effector = {
|
return true
|
||||||
action_on = on_mesecons_signal_open_top,
|
end
|
||||||
rules = mesecon.rules.flat,
|
return false
|
||||||
}},
|
end
|
||||||
|
|
||||||
on_rotate = function(top, node, user, mode, param2)
|
minetest.register_node(name.."_t_1", _t_1_def)
|
||||||
if mode == screwdriver.ROTATE_FACE then
|
|
||||||
local meta_top = minetest_get_meta(top)
|
|
||||||
meta_top:set_int("rotation", 1)
|
|
||||||
node.param2 = screwdriver.rotate.facedir(top, node, mode)
|
|
||||||
minetest.swap_node(top, node)
|
|
||||||
|
|
||||||
local bottom = {x=top.x,y=top.y-1,z=top.z}
|
|
||||||
local meta_bottom = minetest_get_meta(bottom)
|
|
||||||
meta_bottom:set_int("rotation", 1)
|
|
||||||
node.name = name .."_b_1"
|
|
||||||
minetest.swap_node(bottom, node)
|
|
||||||
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
return false
|
|
||||||
end,
|
|
||||||
|
|
||||||
can_dig = check_player_priv,
|
|
||||||
})
|
|
||||||
|
|
||||||
if def.only_redstone_can_open then
|
if def.only_redstone_can_open then
|
||||||
on_rightclick = nil
|
on_rightclick = nil
|
||||||
|
@ -448,66 +425,43 @@ function mcl_doors:register_door(name, def)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_node(name.."_b_2", {
|
local _b_2_def = table.copy(template_def)
|
||||||
tiles = {"blank.png", tbbm, tbs, tbs, tb, tbm},
|
_b_2_def.tiles = {"blank.png", texture_bottom_bottompart_mirrored, texture_bottom_side, texture_bottom_side, texture_bottom, texture_bottom_mirrored}
|
||||||
use_texture_alpha = minetest.features.use_texture_alpha_string_modes and "clip" or true,
|
_b_2_def.after_destruct = function(bottom, oldnode)
|
||||||
paramtype = "light",
|
local meta_bottom = minetest_get_meta(bottom)
|
||||||
paramtype2 = "facedir",
|
if meta_bottom:get_int("rotation") == 1 then
|
||||||
sunlight_propagates = true,
|
meta_bottom:set_int("rotation", 0)
|
||||||
is_ground_content = false,
|
else
|
||||||
drop = "",
|
local top = { x = bottom.x, y = bottom.y + 1, z = bottom.z }
|
||||||
drawtype = "nodebox",
|
minetest.add_item(bottom, name)
|
||||||
groups = def.groups,
|
if minetest.get_node(bottom).name ~= name.."_b_1" and minetest.get_node(top).name == name.."_t_2" then
|
||||||
_mcl_hardness = def._mcl_hardness,
|
minetest.remove_node(top)
|
||||||
_mcl_blast_resistance = def._mcl_blast_resistance,
|
end
|
||||||
sounds = def.sounds,
|
end
|
||||||
node_box = {
|
end
|
||||||
type = "fixed",
|
_b_2_def.on_rightclick = on_rightclick
|
||||||
fixed = def.node_box_bottom
|
_b_2_def.mesecons = { effector = {
|
||||||
},
|
action_off = on_mesecons_signal_close,
|
||||||
selection_box = {
|
}}
|
||||||
type = "fixed",
|
_b_2_def.on_rotate = function(bottom, node, user, mode, param2)
|
||||||
fixed = def.selection_box_bottom
|
if mode == screwdriver.ROTATE_FACE then
|
||||||
},
|
|
||||||
after_destruct = function(bottom, oldnode)
|
|
||||||
local meta_bottom = minetest_get_meta(bottom)
|
local meta_bottom = minetest_get_meta(bottom)
|
||||||
if meta_bottom:get_int("rotation") == 1 then
|
meta_bottom:set_int("rotation", 1)
|
||||||
meta_bottom:set_int("rotation", 0)
|
node.param2 = screwdriver.rotate.facedir(bottom, node, mode)
|
||||||
else
|
minetest.swap_node(bottom, node)
|
||||||
local top = { x = bottom.x, y = bottom.y + 1, z = bottom.z }
|
|
||||||
minetest.add_item(bottom, name)
|
|
||||||
if minetest.get_node(bottom).name ~= name.."_b_1" and minetest.get_node(top).name == name.."_t_2" then
|
|
||||||
minetest.remove_node(top)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
|
|
||||||
on_rightclick = on_rightclick,
|
local top = {x=bottom.x,y=bottom.y+1,z=bottom.z}
|
||||||
|
local meta_top = minetest_get_meta(top)
|
||||||
|
meta_top:set_int("rotation", 1)
|
||||||
|
node.name = name .."_t_2"
|
||||||
|
minetest.swap_node(top, node)
|
||||||
|
|
||||||
mesecons = { effector = {
|
return true
|
||||||
action_off = on_mesecons_signal_close,
|
end
|
||||||
}},
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
on_rotate = function(bottom, node, user, mode, param2)
|
minetest.register_node(name.."_b_2", _b_2_def)
|
||||||
if mode == screwdriver.ROTATE_FACE then
|
|
||||||
local meta_bottom = minetest_get_meta(bottom)
|
|
||||||
meta_bottom:set_int("rotation", 1)
|
|
||||||
node.param2 = screwdriver.rotate.facedir(bottom, node, mode)
|
|
||||||
minetest.swap_node(bottom, node)
|
|
||||||
|
|
||||||
local top = {x=bottom.x,y=bottom.y+1,z=bottom.z}
|
|
||||||
local meta_top = minetest_get_meta(top)
|
|
||||||
meta_top:set_int("rotation", 1)
|
|
||||||
node.name = name .."_t_2"
|
|
||||||
minetest.swap_node(top, node)
|
|
||||||
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
return false
|
|
||||||
end,
|
|
||||||
|
|
||||||
can_dig = check_player_priv,
|
|
||||||
})
|
|
||||||
|
|
||||||
if def.only_redstone_can_open then
|
if def.only_redstone_can_open then
|
||||||
on_rightclick = nil
|
on_rightclick = nil
|
||||||
|
@ -519,66 +473,43 @@ function mcl_doors:register_door(name, def)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_node(name.."_t_2", {
|
local _t_2_def = table.copy(template_def)
|
||||||
tiles = {tttm, "blank.png", tts, tts, tt, ttm},
|
_t_2_def.tiles = {texture_top_toppart_mirrored, "blank.png", texture_top_side, texture_top_side, texture_top, texture_top_mirrored}
|
||||||
use_texture_alpha = minetest.features.use_texture_alpha_string_modes and "clip" or true,
|
_t_2_def.after_destruct = function(top, oldnode)
|
||||||
paramtype = "light",
|
local meta_top = minetest_get_meta(top)
|
||||||
paramtype2 = "facedir",
|
if meta_top:get_int("rotation") == 1 then
|
||||||
sunlight_propagates = true,
|
meta_top:set_int("rotation", 0)
|
||||||
is_ground_content = false,
|
else
|
||||||
drop = "",
|
local bottom = { x = top.x, y = top.y - 1, z = top.z }
|
||||||
drawtype = "nodebox",
|
if minetest.get_node(top).name ~= name.."_t_1" and minetest.get_node(bottom).name == name.."_b_2" and oldnode.name == name.."_t_2" then
|
||||||
groups = def.groups,
|
minetest.dig_node(bottom)
|
||||||
_mcl_hardness = def._mcl_hardness,
|
end
|
||||||
_mcl_blast_resistance = def._mcl_blast_resistance,
|
end
|
||||||
sounds = def.sounds,
|
end
|
||||||
node_box = {
|
_t_2_def.on_rightclick = on_rightclick
|
||||||
type = "fixed",
|
_t_2_def.mesecons = { effector = {
|
||||||
fixed = def.node_box_top
|
action_off = on_mesecons_signal_close_top,
|
||||||
},
|
rules = mesecon.rules.flat,
|
||||||
selection_box = {
|
}}
|
||||||
type = "fixed",
|
_t_2_def.on_rotate = function(top, node, user, mode, param2)
|
||||||
fixed = def.selection_box_top
|
if mode == screwdriver.ROTATE_FACE then
|
||||||
},
|
|
||||||
after_destruct = function(top, oldnode)
|
|
||||||
local meta_top = minetest_get_meta(top)
|
local meta_top = minetest_get_meta(top)
|
||||||
if meta_top:get_int("rotation") == 1 then
|
meta_top:set_int("rotation", 1)
|
||||||
meta_top:set_int("rotation", 0)
|
node.param2 = screwdriver.rotate.facedir(top, node, mode)
|
||||||
else
|
minetest.swap_node(top, node)
|
||||||
local bottom = { x = top.x, y = top.y - 1, z = top.z }
|
|
||||||
if minetest.get_node(top).name ~= name.."_t_1" and minetest.get_node(bottom).name == name.."_b_2" and oldnode.name == name.."_t_2" then
|
|
||||||
minetest.dig_node(bottom)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
|
|
||||||
on_rightclick = on_rightclick,
|
local bottom = {x=top.x,y=top.y-1,z=top.z}
|
||||||
|
local meta_bottom = minetest_get_meta(bottom)
|
||||||
|
meta_bottom:set_int("rotation", 1)
|
||||||
|
node.name = name .."_b_2"
|
||||||
|
minetest.swap_node(bottom, node)
|
||||||
|
|
||||||
mesecons = { effector = {
|
return true
|
||||||
action_off = on_mesecons_signal_close_top,
|
end
|
||||||
rules = mesecon.rules.flat,
|
return false
|
||||||
}},
|
end
|
||||||
|
|
||||||
on_rotate = function(top, node, user, mode, param2)
|
minetest.register_node(name.."_t_2", _t_2_def)
|
||||||
if mode == screwdriver.ROTATE_FACE then
|
|
||||||
local meta_top = minetest_get_meta(top)
|
|
||||||
meta_top:set_int("rotation", 1)
|
|
||||||
node.param2 = screwdriver.rotate.facedir(top, node, mode)
|
|
||||||
minetest.swap_node(top, node)
|
|
||||||
|
|
||||||
local bottom = {x=top.x,y=top.y-1,z=top.z}
|
|
||||||
local meta_bottom = minetest_get_meta(bottom)
|
|
||||||
meta_bottom:set_int("rotation", 1)
|
|
||||||
node.name = name .."_b_2"
|
|
||||||
minetest.swap_node(bottom, node)
|
|
||||||
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
return false
|
|
||||||
end,
|
|
||||||
|
|
||||||
can_dig = check_player_priv,
|
|
||||||
})
|
|
||||||
|
|
||||||
if not def.only_redstone_can_open then
|
if not def.only_redstone_can_open then
|
||||||
on_rightclick = function(pos, node, clicker)
|
on_rightclick = function(pos, node, clicker)
|
||||||
|
@ -588,67 +519,43 @@ function mcl_doors:register_door(name, def)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_node(name.."_b_3", {
|
local _b_3_def = table.copy(template_def)
|
||||||
tiles = {"blank.png", tbm .. "^[transformFY", tbs, tbsm, tb, tbm},
|
_b_3_def.tiles = {"blank.png", texture_bottom_mirrored .. "^[transformFY", texture_bottom_side, texture_bottom_side_mirrored, texture_bottom, texture_bottom_mirrored}
|
||||||
use_texture_alpha = minetest.features.use_texture_alpha_string_modes and "clip" or true,
|
_b_3_def.after_destruct = function(bottom, oldnode)
|
||||||
paramtype = "light",
|
local meta_bottom = minetest_get_meta(bottom)
|
||||||
paramtype2 = "facedir",
|
if meta_bottom:get_int("rotation") == 1 then
|
||||||
sunlight_propagates = true,
|
meta_bottom:set_int("rotation", 0)
|
||||||
is_ground_content = false,
|
else
|
||||||
drop = "",
|
minetest.add_item(bottom, name)
|
||||||
drawtype = "nodebox",
|
local top = { x = bottom.x, y = bottom.y + 1, z = bottom.z }
|
||||||
node_box = {
|
if minetest.get_node(bottom).name ~= name.."_b_4" and minetest.get_node(top).name == name.."_t_3" then
|
||||||
type = "fixed",
|
minetest.remove_node(top)
|
||||||
fixed = def.node_box_bottom
|
end
|
||||||
},
|
end
|
||||||
selection_box = {
|
end
|
||||||
type = "fixed",
|
_b_3_def.on_rightclick = on_rightclick
|
||||||
fixed = def.selection_box_bottom
|
_b_3_def.mesecons = { effector = {
|
||||||
},
|
action_on = on_mesecons_signal_open,
|
||||||
groups = def.groups,
|
}}
|
||||||
_mcl_hardness = def._mcl_hardness,
|
_b_3_def.on_rotate = function(bottom, node, user, mode, param2)
|
||||||
_mcl_blast_resistance = def._mcl_blast_resistance,
|
if mode == screwdriver.ROTATE_FACE then
|
||||||
sounds = def.sounds,
|
|
||||||
|
|
||||||
after_destruct = function(bottom, oldnode)
|
|
||||||
local meta_bottom = minetest_get_meta(bottom)
|
local meta_bottom = minetest_get_meta(bottom)
|
||||||
if meta_bottom:get_int("rotation") == 1 then
|
meta_bottom:set_int("rotation", 1)
|
||||||
meta_bottom:set_int("rotation", 0)
|
node.param2 = screwdriver.rotate.facedir(bottom, node, mode)
|
||||||
else
|
minetest.swap_node(bottom, node)
|
||||||
minetest.add_item(bottom, name)
|
|
||||||
local top = { x = bottom.x, y = bottom.y + 1, z = bottom.z }
|
|
||||||
if minetest.get_node(bottom).name ~= name.."_b_4" and minetest.get_node(top).name == name.."_t_3" then
|
|
||||||
minetest.remove_node(top)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
|
|
||||||
on_rightclick = on_rightclick,
|
local top = {x=bottom.x,y=bottom.y+1,z=bottom.z}
|
||||||
|
local meta_top = minetest_get_meta(top)
|
||||||
|
meta_top:set_int("rotation", 1)
|
||||||
|
node.name = name .."_t_3"
|
||||||
|
minetest.swap_node(top, node)
|
||||||
|
|
||||||
mesecons = { effector = {
|
return true
|
||||||
action_on = on_mesecons_signal_open,
|
end
|
||||||
}},
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
on_rotate = function(bottom, node, user, mode, param2)
|
minetest.register_node(name.."_b_3", _b_3_def)
|
||||||
if mode == screwdriver.ROTATE_FACE then
|
|
||||||
local meta_bottom = minetest_get_meta(bottom)
|
|
||||||
meta_bottom:set_int("rotation", 1)
|
|
||||||
node.param2 = screwdriver.rotate.facedir(bottom, node, mode)
|
|
||||||
minetest.swap_node(bottom, node)
|
|
||||||
|
|
||||||
local top = {x=bottom.x,y=bottom.y+1,z=bottom.z}
|
|
||||||
local meta_top = minetest_get_meta(top)
|
|
||||||
meta_top:set_int("rotation", 1)
|
|
||||||
node.name = name .."_t_3"
|
|
||||||
minetest.swap_node(top, node)
|
|
||||||
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
return false
|
|
||||||
end,
|
|
||||||
|
|
||||||
can_dig = check_player_priv,
|
|
||||||
})
|
|
||||||
|
|
||||||
if def.only_redstone_can_open then
|
if def.only_redstone_can_open then
|
||||||
on_rightclick = nil
|
on_rightclick = nil
|
||||||
|
@ -660,67 +567,43 @@ function mcl_doors:register_door(name, def)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_node(name.."_t_3", {
|
local _t_3_def = table.copy(template_def)
|
||||||
tiles = {ttm .. "^[transformFY", "blank.png", tts, ttsm, tt, ttm},
|
_t_3_def.tiles = {texture_top_mirrored .. "^[transformFY", "blank.png", texture_top_side, texture_top_side_mirrored, texture_top, texture_top_mirrored}
|
||||||
use_texture_alpha = minetest.features.use_texture_alpha_string_modes and "clip" or true,
|
_t_3_def.after_destruct = function(top, oldnode)
|
||||||
paramtype = "light",
|
local meta_top = minetest_get_meta(top)
|
||||||
paramtype2 = "facedir",
|
if meta_top:get_int("rotation") == 1 then
|
||||||
sunlight_propagates = true,
|
meta_top:set_int("rotation", 0)
|
||||||
is_ground_content = false,
|
else
|
||||||
drop = "",
|
local bottom = { x = top.x, y = top.y - 1, z = top.z }
|
||||||
drawtype = "nodebox",
|
if minetest.get_node(top).name ~= name.."_t_4" and minetest.get_node(bottom).name == name.."_b_3" and oldnode.name == name.."_t_3" then
|
||||||
node_box = {
|
minetest.dig_node(bottom)
|
||||||
type = "fixed",
|
end
|
||||||
fixed = def.node_box_top
|
end
|
||||||
},
|
end
|
||||||
selection_box = {
|
_t_3_def.on_rightclick = on_rightclick
|
||||||
type = "fixed",
|
_t_3_def.mesecons = { effector = {
|
||||||
fixed = def.selection_box_top
|
action_on = on_mesecons_signal_open_top,
|
||||||
},
|
rules = mesecon.rules.flat,
|
||||||
groups = def.groups,
|
}}
|
||||||
_mcl_hardness = def._mcl_hardness,
|
_t_3_def.on_rotate = function(top, node, user, mode, param2)
|
||||||
_mcl_blast_resistance = def._mcl_blast_resistance,
|
if mode == screwdriver.ROTATE_FACE then
|
||||||
sounds = def.sounds,
|
|
||||||
|
|
||||||
after_destruct = function(top, oldnode)
|
|
||||||
local meta_top = minetest_get_meta(top)
|
local meta_top = minetest_get_meta(top)
|
||||||
if meta_top:get_int("rotation") == 1 then
|
meta_top:set_int("rotation", 1)
|
||||||
meta_top:set_int("rotation", 0)
|
node.param2 = screwdriver.rotate.facedir(top, node, mode)
|
||||||
else
|
minetest.swap_node(top, node)
|
||||||
local bottom = { x = top.x, y = top.y - 1, z = top.z }
|
|
||||||
if minetest.get_node(top).name ~= name.."_t_4" and minetest.get_node(bottom).name == name.."_b_3" and oldnode.name == name.."_t_3" then
|
|
||||||
minetest.dig_node(bottom)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
|
|
||||||
on_rightclick = on_rightclick,
|
local bottom = {x=top.x,y=top.y-1,z=top.z}
|
||||||
|
local meta_bottom = minetest_get_meta(bottom)
|
||||||
|
meta_bottom:set_int("rotation", 1)
|
||||||
|
node.name = name .."_b_3"
|
||||||
|
minetest.swap_node(bottom, node)
|
||||||
|
|
||||||
mesecons = { effector = {
|
return true
|
||||||
action_on = on_mesecons_signal_open_top,
|
end
|
||||||
rules = mesecon.rules.flat,
|
return false
|
||||||
}},
|
end
|
||||||
|
|
||||||
on_rotate = function(top, node, user, mode, param2)
|
minetest.register_node(name.."_t_3", _t_3_def)
|
||||||
if mode == screwdriver.ROTATE_FACE then
|
|
||||||
local meta_top = minetest_get_meta(top)
|
|
||||||
meta_top:set_int("rotation", 1)
|
|
||||||
node.param2 = screwdriver.rotate.facedir(top, node, mode)
|
|
||||||
minetest.swap_node(top, node)
|
|
||||||
|
|
||||||
local bottom = {x=top.x,y=top.y-1,z=top.z}
|
|
||||||
local meta_bottom = minetest_get_meta(bottom)
|
|
||||||
meta_bottom:set_int("rotation", 1)
|
|
||||||
node.name = name .."_b_3"
|
|
||||||
minetest.swap_node(bottom, node)
|
|
||||||
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
return false
|
|
||||||
end,
|
|
||||||
|
|
||||||
can_dig = check_player_priv,
|
|
||||||
})
|
|
||||||
|
|
||||||
if def.only_redstone_can_open then
|
if def.only_redstone_can_open then
|
||||||
on_rightclick = nil
|
on_rightclick = nil
|
||||||
|
@ -732,66 +615,43 @@ function mcl_doors:register_door(name, def)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_node(name.."_b_4", {
|
local _b_4_def = table.copy(template_def)
|
||||||
tiles = {"blank.png", tbb, tbsm, tbsm, tbm, tb},
|
_b_4_def.tiles = {"blank.png", texture_bottom_bottompart, texture_bottom_side_mirrored, texture_bottom_side_mirrored, texture_bottom_mirrored, texture_bottom}
|
||||||
use_texture_alpha = minetest.features.use_texture_alpha_string_modes and "clip" or true,
|
_b_4_def.after_destruct = function(bottom, oldnode)
|
||||||
paramtype = "light",
|
local meta_bottom = minetest_get_meta(bottom)
|
||||||
paramtype2 = "facedir",
|
if meta_bottom:get_int("rotation") == 1 then
|
||||||
sunlight_propagates = true,
|
meta_bottom:set_int("rotation", 0)
|
||||||
is_ground_content = false,
|
else
|
||||||
drop = "",
|
local top = { x = bottom.x, y = bottom.y + 1, z = bottom.z }
|
||||||
drawtype = "nodebox",
|
minetest.add_item(bottom, name)
|
||||||
groups = def.groups,
|
if minetest.get_node(bottom).name ~= name.."_b_3" and minetest.get_node(top).name == name.."_t_4" then
|
||||||
_mcl_hardness = def._mcl_hardness,
|
minetest.remove_node(top)
|
||||||
_mcl_blast_resistance = def._mcl_blast_resistance,
|
end
|
||||||
sounds = def.sounds,
|
end
|
||||||
node_box = {
|
end
|
||||||
type = "fixed",
|
_b_4_def.on_rightclick = on_rightclick
|
||||||
fixed = def.node_box_bottom
|
_b_4_def.mesecons = { effector = {
|
||||||
},
|
action_off = on_mesecons_signal_close,
|
||||||
selection_box = {
|
}}
|
||||||
type = "fixed",
|
_b_4_def.on_rotate = function(bottom, node, user, mode, param2)
|
||||||
fixed = def.selection_box_bottom
|
if mode == screwdriver.ROTATE_FACE then
|
||||||
},
|
|
||||||
after_destruct = function(bottom, oldnode)
|
|
||||||
local meta_bottom = minetest_get_meta(bottom)
|
local meta_bottom = minetest_get_meta(bottom)
|
||||||
if meta_bottom:get_int("rotation") == 1 then
|
meta_bottom:set_int("rotation", 1)
|
||||||
meta_bottom:set_int("rotation", 0)
|
node.param2 = screwdriver.rotate.facedir(bottom, node, mode)
|
||||||
else
|
minetest.swap_node(bottom, node)
|
||||||
local top = { x = bottom.x, y = bottom.y + 1, z = bottom.z }
|
|
||||||
minetest.add_item(bottom, name)
|
|
||||||
if minetest.get_node(bottom).name ~= name.."_b_3" and minetest.get_node(top).name == name.."_t_4" then
|
|
||||||
minetest.remove_node(top)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
|
|
||||||
on_rightclick = on_rightclick,
|
local top = {x=bottom.x,y=bottom.y+1,z=bottom.z}
|
||||||
|
local meta_top = minetest_get_meta(top)
|
||||||
|
meta_top:set_int("rotation", 1)
|
||||||
|
node.name = name .."_t_4"
|
||||||
|
minetest.swap_node(top, node)
|
||||||
|
|
||||||
mesecons = { effector = {
|
return true
|
||||||
action_off = on_mesecons_signal_close,
|
end
|
||||||
}},
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
on_rotate = function(bottom, node, user, mode, param2)
|
minetest.register_node(name.."_b_4", _b_4_def)
|
||||||
if mode == screwdriver.ROTATE_FACE then
|
|
||||||
local meta_bottom = minetest_get_meta(bottom)
|
|
||||||
meta_bottom:set_int("rotation", 1)
|
|
||||||
node.param2 = screwdriver.rotate.facedir(bottom, node, mode)
|
|
||||||
minetest.swap_node(bottom, node)
|
|
||||||
|
|
||||||
local top = {x=bottom.x,y=bottom.y+1,z=bottom.z}
|
|
||||||
local meta_top = minetest_get_meta(top)
|
|
||||||
meta_top:set_int("rotation", 1)
|
|
||||||
node.name = name .."_t_4"
|
|
||||||
minetest.swap_node(top, node)
|
|
||||||
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
return false
|
|
||||||
end,
|
|
||||||
|
|
||||||
can_dig = check_player_priv,
|
|
||||||
})
|
|
||||||
|
|
||||||
if def.only_redstone_can_open then
|
if def.only_redstone_can_open then
|
||||||
on_rightclick = nil
|
on_rightclick = nil
|
||||||
|
@ -803,66 +663,43 @@ function mcl_doors:register_door(name, def)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_node(name.."_t_4", {
|
local _t_4_def = table.copy(template_def)
|
||||||
tiles = {ttt, "blank.png", ttsm, ttsm, ttm, tt},
|
_t_4_def.tiles = {texture_top_toppart, "blank.png", texture_top_side_mirrored, texture_top_side_mirrored, texture_top_mirrored, texture_top}
|
||||||
use_texture_alpha = minetest.features.use_texture_alpha_string_modes and "clip" or true,
|
_t_4_def.after_destruct = function(top, oldnode)
|
||||||
paramtype = "light",
|
local meta_top = minetest_get_meta(top)
|
||||||
paramtype2 = "facedir",
|
if meta_top:get_int("rotation") == 1 then
|
||||||
sunlight_propagates = true,
|
meta_top:set_int("rotation", 0)
|
||||||
is_ground_content = false,
|
else
|
||||||
drop = "",
|
local bottom = { x = top.x, y = top.y - 1, z = top.z }
|
||||||
drawtype = "nodebox",
|
if minetest.get_node(top).name ~= name.."_t_3" and minetest.get_node(bottom).name == name.."_b_4" and oldnode.name == name.."_t_4" then
|
||||||
groups = def.groups,
|
minetest.dig_node(bottom)
|
||||||
_mcl_hardness = def._mcl_hardness,
|
end
|
||||||
_mcl_blast_resistance = def._mcl_blast_resistance,
|
end
|
||||||
sounds = def.sounds,
|
end
|
||||||
node_box = {
|
_t_4_def.on_rightclick = on_rightclick
|
||||||
type = "fixed",
|
_t_4_def.mesecons = { effector = {
|
||||||
fixed = def.node_box_top
|
action_off = on_mesecons_signal_close_top,
|
||||||
},
|
rules = mesecon.rules.flat,
|
||||||
selection_box = {
|
}}
|
||||||
type = "fixed",
|
_t_4_def.on_rotate = function(top, node, user, mode, param2)
|
||||||
fixed = def.selection_box_top
|
if mode == screwdriver.ROTATE_FACE then
|
||||||
},
|
|
||||||
after_destruct = function(top, oldnode)
|
|
||||||
local meta_top = minetest_get_meta(top)
|
local meta_top = minetest_get_meta(top)
|
||||||
if meta_top:get_int("rotation") == 1 then
|
meta_top:set_int("rotation", 1)
|
||||||
meta_top:set_int("rotation", 0)
|
node.param2 = screwdriver.rotate.facedir(top, node, mode)
|
||||||
else
|
minetest.swap_node(top, node)
|
||||||
local bottom = { x = top.x, y = top.y - 1, z = top.z }
|
|
||||||
if minetest.get_node(top).name ~= name.."_t_3" and minetest.get_node(bottom).name == name.."_b_4" and oldnode.name == name.."_t_4" then
|
|
||||||
minetest.dig_node(bottom)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
|
|
||||||
on_rightclick = on_rightclick,
|
local bottom = {x=top.x,y=top.y-1,z=top.z}
|
||||||
|
local meta_bottom = minetest_get_meta(bottom)
|
||||||
|
meta_bottom:set_int("rotation", 1)
|
||||||
|
node.name = name .."_b_4"
|
||||||
|
minetest.swap_node(bottom, node)
|
||||||
|
|
||||||
mesecons = { effector = {
|
return true
|
||||||
action_off = on_mesecons_signal_close_top,
|
end
|
||||||
rules = mesecon.rules.flat,
|
return false
|
||||||
}},
|
end
|
||||||
|
|
||||||
on_rotate = function(top, node, user, mode, param2)
|
minetest.register_node(name.."_t_4", _t_4_def)
|
||||||
if mode == screwdriver.ROTATE_FACE then
|
|
||||||
local meta_top = minetest_get_meta(top)
|
|
||||||
meta_top:set_int("rotation", 1)
|
|
||||||
node.param2 = screwdriver.rotate.facedir(top, node, mode)
|
|
||||||
minetest.swap_node(top, node)
|
|
||||||
|
|
||||||
local bottom = {x=top.x,y=top.y-1,z=top.z}
|
|
||||||
local meta_bottom = minetest_get_meta(bottom)
|
|
||||||
meta_bottom:set_int("rotation", 1)
|
|
||||||
node.name = name .."_b_4"
|
|
||||||
minetest.swap_node(bottom, node)
|
|
||||||
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
return false
|
|
||||||
end,
|
|
||||||
|
|
||||||
can_dig = check_player_priv,
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
-- Add entry aliases for the Help
|
-- Add entry aliases for the Help
|
||||||
|
|
Loading…
Reference in New Issue