Trapdoors: Simplify nodeboxes, add metal sounds, refactor code
parent
2c282830b6
commit
b7df3a9bd4
|
@ -174,9 +174,9 @@ function doors:register_door(name, def)
|
||||||
if check_player_priv(pos, clicker) then
|
if check_player_priv(pos, clicker) then
|
||||||
on_rightclick(pos, 1, name.."_t_1", name.."_b_2", name.."_t_2", {1,2,3,0})
|
on_rightclick(pos, 1, name.."_t_1", name.."_b_2", name.."_t_2", {1,2,3,0})
|
||||||
if is_right(pos, clicker) then
|
if is_right(pos, clicker) then
|
||||||
minetest.sound_play("door_close", {pos = pos, gain = 0.3, max_hear_distance = 10})
|
minetest.sound_play("doors_door_close", {pos = pos, gain = 0.3, max_hear_distance = 10})
|
||||||
else
|
else
|
||||||
minetest.sound_play("door_open", {pos = pos, gain = 0.3, max_hear_distance = 10})
|
minetest.sound_play("doors_door_open", {pos = pos, gain = 0.3, max_hear_distance = 10})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
@ -210,9 +210,9 @@ function doors:register_door(name, def)
|
||||||
if check_player_priv(pos, clicker) then
|
if check_player_priv(pos, clicker) then
|
||||||
on_rightclick(pos, -1, name.."_b_1", name.."_t_2", name.."_b_2", {1,2,3,0})
|
on_rightclick(pos, -1, name.."_b_1", name.."_t_2", name.."_b_2", {1,2,3,0})
|
||||||
if is_right(pos, clicker) then
|
if is_right(pos, clicker) then
|
||||||
minetest.sound_play("door_close", {pos = pos, gain = 0.3, max_hear_distance = 10})
|
minetest.sound_play("doors_door_close", {pos = pos, gain = 0.3, max_hear_distance = 10})
|
||||||
else
|
else
|
||||||
minetest.sound_play("door_open", {pos = pos, gain = 0.3, max_hear_distance = 10})
|
minetest.sound_play("doors_door_open", {pos = pos, gain = 0.3, max_hear_distance = 10})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
@ -246,9 +246,9 @@ function doors:register_door(name, def)
|
||||||
if check_player_priv(pos, clicker) then
|
if check_player_priv(pos, clicker) then
|
||||||
on_rightclick(pos, 1, name.."_t_2", name.."_b_1", name.."_t_1", {3,0,1,2})
|
on_rightclick(pos, 1, name.."_t_2", name.."_b_1", name.."_t_1", {3,0,1,2})
|
||||||
if is_right(pos, clicker) then
|
if is_right(pos, clicker) then
|
||||||
minetest.sound_play("door_open", {gain = 0.3, max_hear_distance = 10})
|
minetest.sound_play("doors_door_open", {gain = 0.3, max_hear_distance = 10})
|
||||||
else
|
else
|
||||||
minetest.sound_play("door_close", {gain = 0.3, max_hear_distance = 10})
|
minetest.sound_play("doors_door_close", {gain = 0.3, max_hear_distance = 10})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
@ -282,9 +282,9 @@ function doors:register_door(name, def)
|
||||||
if check_player_priv(pos, clicker) then
|
if check_player_priv(pos, clicker) then
|
||||||
on_rightclick(pos, -1, name.."_b_2", name.."_t_1", name.."_b_1", {3,0,1,2})
|
on_rightclick(pos, -1, name.."_b_2", name.."_t_1", name.."_b_1", {3,0,1,2})
|
||||||
if is_right(pos, clicker) then
|
if is_right(pos, clicker) then
|
||||||
minetest.sound_play("door_open", {pos=pos, gain = 0.3, max_hear_distance = 10})
|
minetest.sound_play("doors_door_open", {pos=pos, gain = 0.3, max_hear_distance = 10})
|
||||||
else
|
else
|
||||||
minetest.sound_play("door_close", {gain = 0.3, max_hear_distance = 10})
|
minetest.sound_play("doors_door_close", {gain = 0.3, max_hear_distance = 10})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
@ -464,116 +464,113 @@ minetest.register_alias("doors:door_wood_b_c", "doors:door_wood_b_1")
|
||||||
minetest.register_alias("doors:door_wood_b_o", "doors:door_wood_b_1")
|
minetest.register_alias("doors:door_wood_b_o", "doors:door_wood_b_1")
|
||||||
|
|
||||||
|
|
||||||
----trapdoor Wood----
|
---- Trapdoor ----
|
||||||
|
|
||||||
local me
|
function doors:register_trapdoor(name, def)
|
||||||
local meta
|
local function update_door(pos, node)
|
||||||
local state = 0
|
minetest.set_node(pos, node)
|
||||||
|
end
|
||||||
|
|
||||||
local function update_door(pos, node)
|
local me
|
||||||
minetest.set_node(pos, node)
|
local meta
|
||||||
end
|
local state = 0
|
||||||
|
|
||||||
local function punch(pos)
|
if not def.sound_open then
|
||||||
meta = minetest.get_meta(pos)
|
def.sound_open = "doors_door_open"
|
||||||
state = meta:get_int("state")
|
end
|
||||||
me = minetest.get_node(pos)
|
if not def.sound_close then
|
||||||
local tmp_node
|
def.sound_close = "doors_door_close"
|
||||||
local tmp_node2
|
end
|
||||||
local oben = {x=pos.x, y=pos.y+1, z=pos.z}
|
|
||||||
|
local function punch(pos)
|
||||||
|
meta = minetest.get_meta(pos)
|
||||||
|
state = meta:get_int("state")
|
||||||
|
me = minetest.get_node(pos)
|
||||||
|
local tmp_node
|
||||||
|
local tmp_node2
|
||||||
|
local oben = {x=pos.x, y=pos.y+1, z=pos.z}
|
||||||
if state == 1 then
|
if state == 1 then
|
||||||
state = 0
|
state = 0
|
||||||
minetest.sound_play("door_close", {pos = pos, gain = 0.3, max_hear_distance = 10})
|
minetest.sound_play(def.sound_close, {pos = pos, gain = 0.3, max_hear_distance = 10})
|
||||||
tmp_node = {name="doors:trapdoor", param1=me.param1, param2=me.param2}
|
tmp_node = {name=name, param1=me.param1, param2=me.param2}
|
||||||
else
|
else
|
||||||
state = 1
|
state = 1
|
||||||
minetest.sound_play("door_open", {pos = pos, gain = 0.3, max_hear_distance = 10})
|
minetest.sound_play(def.sound_open, {pos = pos, gain = 0.3, max_hear_distance = 10})
|
||||||
tmp_node = {name="doors:trapdoor_open", param1=me.param1, param2=me.param2}
|
tmp_node = {name=name.."_open", param1=me.param1, param2=me.param2}
|
||||||
end
|
end
|
||||||
update_door(pos, tmp_node)
|
update_door(pos, tmp_node)
|
||||||
meta:set_int("state", state)
|
meta:set_int("state", state)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
minetest.register_node(name, {
|
||||||
|
description = def.description,
|
||||||
|
drawtype = "nodebox",
|
||||||
|
tiles = def.tiles,
|
||||||
|
inventory_image = def.inventory_image,
|
||||||
|
wield_image = def.wield_image,
|
||||||
|
is_ground_content = false,
|
||||||
|
paramtype = "light",
|
||||||
|
stack_max = 64,
|
||||||
|
paramtype2 = "facedir",
|
||||||
|
groups = def.groups,
|
||||||
|
sounds = def.sounds,
|
||||||
|
node_box = {
|
||||||
|
type = "fixed",
|
||||||
|
fixed = {
|
||||||
|
{-8/16, -8/16, -8/16, 8/16, -6/16, 8/16},},
|
||||||
|
},
|
||||||
|
on_creation = function(pos)
|
||||||
|
state = 0
|
||||||
|
end,
|
||||||
|
mesecons = {effector = {
|
||||||
|
action_on = (function(pos, node)
|
||||||
|
punch(pos)
|
||||||
|
end),
|
||||||
|
}},
|
||||||
|
on_rightclick = function(pos, node, clicker)
|
||||||
|
punch(pos)
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
minetest.register_node("doors:trapdoor", {
|
minetest.register_node(name.."_open", {
|
||||||
description = "Wooden Trapdoor",
|
drawtype = "nodebox",
|
||||||
drawtype = "nodebox",
|
tiles = def.tiles,
|
||||||
tiles = {"door_trapdoor.png"},
|
is_ground_content = false,
|
||||||
is_ground_content = false,
|
paramtype = "light",
|
||||||
paramtype = "light",
|
paramtype2 = "facedir",
|
||||||
stack_max = 64,
|
pointable = true,
|
||||||
paramtype2 = "facedir",
|
groups = def.groups,
|
||||||
groups = {snappy=1,choppy=2,oddly_breakable_by_hand=2,mesecon_effector_on=1,door=2},
|
sounds = def.sounds,
|
||||||
sounds = mcl_sounds.node_sound_wood_defaults(),
|
drop = name,
|
||||||
drop = "doors:trapdoor",
|
node_box = {
|
||||||
node_box = {
|
type = "fixed",
|
||||||
type = "fixed",
|
fixed = {-0.5, -0.5, 0.4, 0.5, 0.5, 0.5}
|
||||||
fixed = {
|
|
||||||
{-8/16, -8/16, -8/16, -5/16, -6/16, 8/16},--left
|
|
||||||
{5/16, -8/16, -8/16, 8/16, -6/16, 8/16}, --right
|
|
||||||
{-8/16, -8/16, -8/16, 8/16, -6/16, -5/16},--down
|
|
||||||
{-8/16, -8/16, 5/16, 8/16, -6/16, 8/16}, --up
|
|
||||||
{-2/16, -8/16, -5/16, 2/16, -6/16, 5/16}, --vert mid
|
|
||||||
{-5/16, -8/16, -2/16, 5/16, -6/16, 2/16}, --hori mid
|
|
||||||
},
|
},
|
||||||
},
|
selection_box = {
|
||||||
selection_box = {
|
type = "fixed",
|
||||||
type = "fixed",
|
fixed = {-0.5, -0.5, 0.4, 0.5, 0.5, 0.5}
|
||||||
fixed = {
|
|
||||||
{-8/16, -8/16, -8/16, -5/16, -6/16, 8/16},--left
|
|
||||||
{5/16, -8/16, -8/16, 8/16, -6/16, 8/16}, --right
|
|
||||||
{-8/16, -8/16, -8/16, 8/16, -6/16, -5/16},--down
|
|
||||||
{-8/16, -8/16, 5/16, 8/16, -6/16, 8/16}, --up
|
|
||||||
{-2/16, -8/16, -5/16, 2/16, -6/16, 5/16}, --vert mid
|
|
||||||
{-5/16, -8/16, -2/16, 5/16, -6/16, 2/16}, --hori mid
|
|
||||||
},
|
},
|
||||||
},
|
on_rightclick = function(pos, node, clicker)
|
||||||
on_creation = function(pos)
|
punch(pos)
|
||||||
state = 0
|
end,
|
||||||
end,
|
mesecons = {effector = {
|
||||||
mesecons = {effector = {
|
|
||||||
action_on = (function(pos, node)
|
action_on = (function(pos, node)
|
||||||
punch(pos)
|
punch(pos)
|
||||||
end),
|
end),
|
||||||
}},
|
}},
|
||||||
on_rightclick = function(pos, node, clicker)
|
})
|
||||||
punch(pos)
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
minetest.register_node("doors:trapdoor_open", {
|
end
|
||||||
drawtype = "nodebox",
|
|
||||||
|
doors:register_trapdoor("doors:trapdoor", {
|
||||||
|
description = "Wooden Trapdoor",
|
||||||
tiles = {"door_trapdoor.png"},
|
tiles = {"door_trapdoor.png"},
|
||||||
is_ground_content = false,
|
wield_image = "door_trapdoor.png",
|
||||||
paramtype = "light",
|
|
||||||
paramtype2 = "facedir",
|
|
||||||
pointable = true,
|
|
||||||
groups = {snappy=1,choppy=2,oddly_breakable_by_hand=2,mesecon_effector_on=1,door=2},
|
groups = {snappy=1,choppy=2,oddly_breakable_by_hand=2,mesecon_effector_on=1,door=2},
|
||||||
sounds = mcl_sounds.node_sound_wood_defaults(),
|
sounds = mcl_sounds.node_sound_wood_defaults(),
|
||||||
drop = "doors:trapdoor",
|
|
||||||
node_box = {
|
|
||||||
type = "fixed",
|
|
||||||
fixed = {-0.5, -0.5, 0.4, 0.5, 0.5, 0.5}
|
|
||||||
},
|
|
||||||
selection_box = {
|
|
||||||
type = "fixed",
|
|
||||||
fixed = {-0.5, -0.5, 0.4, 0.5, 0.5, 0.5}
|
|
||||||
},
|
|
||||||
on_rightclick = function(pos, node, clicker)
|
|
||||||
punch(pos)
|
|
||||||
end,
|
|
||||||
mesecons = {effector = {
|
|
||||||
action_on = (function(pos, node)
|
|
||||||
punch(pos)
|
|
||||||
end),
|
|
||||||
}},
|
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
output = 'doors:trapdoor 2',
|
output = 'doors:trapdoor 2',
|
||||||
recipe = {
|
recipe = {
|
||||||
|
@ -588,109 +585,14 @@ minetest.register_craft({
|
||||||
burntime = 15,
|
burntime = 15,
|
||||||
})
|
})
|
||||||
|
|
||||||
--- Iron Trapdoor ----
|
doors:register_trapdoor("doors:iron_trapdoor", {
|
||||||
local me
|
|
||||||
local meta
|
|
||||||
local state = 0
|
|
||||||
|
|
||||||
local function update_door(pos, node)
|
|
||||||
minetest.set_node(pos, node)
|
|
||||||
end
|
|
||||||
|
|
||||||
local function punch(pos)
|
|
||||||
meta = minetest.get_meta(pos)
|
|
||||||
state = meta:get_int("state")
|
|
||||||
me = minetest.get_node(pos)
|
|
||||||
local tmp_node
|
|
||||||
local tmp_node2
|
|
||||||
local oben = {x=pos.x, y=pos.y+1, z=pos.z}
|
|
||||||
if state == 1 then
|
|
||||||
state = 0
|
|
||||||
minetest.sound_play("door_close", {pos = pos, gain = 0.3, max_hear_distance = 10})
|
|
||||||
tmp_node = {name="doors:iron_trapdoor", param1=me.param1, param2=me.param2}
|
|
||||||
else
|
|
||||||
state = 1
|
|
||||||
minetest.sound_play("door_open", {pos = pos, gain = 0.3, max_hear_distance = 10})
|
|
||||||
tmp_node = {name="doors:iron_trapdoor_open", param1=me.param1, param2=me.param2}
|
|
||||||
end
|
|
||||||
update_door(pos, tmp_node)
|
|
||||||
meta:set_int("state", state)
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
minetest.register_node("doors:iron_trapdoor", {
|
|
||||||
description = "Iron Trapdoor",
|
description = "Iron Trapdoor",
|
||||||
drawtype = "nodebox",
|
tiles = {"iron_trapdoor.png"},
|
||||||
tiles = {"iron_trapdoor.png", "iron_trapdoor.png", "default_steel_block.png", "default_steel_block.png", "default_steel_block.png", "default_steel_block.png"},
|
wield_image = "iron_trapdoor.png",
|
||||||
paramtype = "light",
|
groups = {cracky=2,mesecon_effector_on=1,door=2},
|
||||||
is_ground_content = false,
|
sounds = mcl_sounds.node_sound_metal_defaults(),
|
||||||
stack_max = 64,
|
sound_open = "doors_steel_door_open",
|
||||||
paramtype2 = "facedir",
|
sound_close = "doors_steel_door_close",
|
||||||
groups = {snappy=1,choppy=2,oddly_breakable_by_hand=2,mesecon_effector_on=1,door=2},
|
|
||||||
sounds = mcl_sounds.node_sound_wood_defaults(),
|
|
||||||
drop = "doors:iron_trapdoor",
|
|
||||||
node_box = {
|
|
||||||
type = "fixed",
|
|
||||||
fixed = {
|
|
||||||
{-8/16, -8/16, -8/16, -5/16, -6/16, 8/16},--left
|
|
||||||
{5/16, -8/16, -8/16, 8/16, -6/16, 8/16}, --right
|
|
||||||
{-8/16, -8/16, -8/16, 8/16, -6/16, -5/16},--down
|
|
||||||
{-8/16, -8/16, 5/16, 8/16, -6/16, 8/16}, --up
|
|
||||||
{-2/16, -8/16, -5/16, 2/16, -6/16, 5/16}, --vert mid
|
|
||||||
{-5/16, -8/16, -2/16, 5/16, -6/16, 2/16}, --hori mid
|
|
||||||
},
|
|
||||||
},
|
|
||||||
selection_box = {
|
|
||||||
type = "fixed",
|
|
||||||
fixed = {
|
|
||||||
{-8/16, -8/16, -8/16, -5/16, -6/16, 8/16},--left
|
|
||||||
{5/16, -8/16, -8/16, 8/16, -6/16, 8/16}, --right
|
|
||||||
{-8/16, -8/16, -8/16, 8/16, -6/16, -5/16},--down
|
|
||||||
{-8/16, -8/16, 5/16, 8/16, -6/16, 8/16}, --up
|
|
||||||
{-2/16, -8/16, -5/16, 2/16, -6/16, 5/16}, --vert mid
|
|
||||||
{-5/16, -8/16, -2/16, 5/16, -6/16, 2/16}, --hori mid
|
|
||||||
},
|
|
||||||
},
|
|
||||||
mesecons = {effector = {
|
|
||||||
action_on = (function(pos, node)
|
|
||||||
punch(pos)
|
|
||||||
end),
|
|
||||||
}},
|
|
||||||
on_creation = function(pos)
|
|
||||||
state = 0
|
|
||||||
end,
|
|
||||||
on_rightclick = function(pos, node, clicker)
|
|
||||||
punch(pos)
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
minetest.register_node("doors:iron_trapdoor_open", {
|
|
||||||
drawtype = "nodebox",
|
|
||||||
tiles = {"default_steel_block.png", "default_steel_block.png", "default_steel_block.png", "default_steel_block.png", "iron_trapdoor.png", "iron_trapdoor.png"},
|
|
||||||
paramtype = "light",
|
|
||||||
paramtype2 = "facedir",
|
|
||||||
is_ground_content = false,
|
|
||||||
pointable = true,
|
|
||||||
groups = {snappy=1,choppy=2,oddly_breakable_by_hand=2,door=2,mesecon_effector_on=1},
|
|
||||||
sounds = mcl_sounds.node_sound_wood_defaults(),
|
|
||||||
drop = "doors:iron_trapdoor",
|
|
||||||
node_box = {
|
|
||||||
type = "fixed",
|
|
||||||
fixed = {-0.5, -0.5, 0.4, 0.5, 0.5, 0.5}
|
|
||||||
},
|
|
||||||
selection_box = {
|
|
||||||
type = "fixed",
|
|
||||||
fixed = {-0.5, -0.5, 0.4, 0.5, 0.5, 0.5}
|
|
||||||
},
|
|
||||||
mesecons = {effector = {
|
|
||||||
action_on = (function(pos, node)
|
|
||||||
punch(pos)
|
|
||||||
end),
|
|
||||||
}},
|
|
||||||
on_rightclick = function(pos, node, clicker)
|
|
||||||
punch(pos)
|
|
||||||
end,
|
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue