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,14 +464,22 @@ 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 ----
|
||||||
|
|
||||||
|
function doors:register_trapdoor(name, def)
|
||||||
|
local function update_door(pos, node)
|
||||||
|
minetest.set_node(pos, node)
|
||||||
|
end
|
||||||
|
|
||||||
local me
|
local me
|
||||||
local meta
|
local meta
|
||||||
local state = 0
|
local state = 0
|
||||||
|
|
||||||
local function update_door(pos, node)
|
if not def.sound_open then
|
||||||
minetest.set_node(pos, node)
|
def.sound_open = "doors_door_open"
|
||||||
|
end
|
||||||
|
if not def.sound_close then
|
||||||
|
def.sound_close = "doors_door_close"
|
||||||
end
|
end
|
||||||
|
|
||||||
local function punch(pos)
|
local function punch(pos)
|
||||||
|
@ -483,50 +491,33 @@ local function punch(pos)
|
||||||
local oben = {x=pos.x, y=pos.y+1, z=pos.z}
|
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, {
|
||||||
minetest.register_node("doors:trapdoor", {
|
description = def.description,
|
||||||
description = "Wooden Trapdoor",
|
|
||||||
drawtype = "nodebox",
|
drawtype = "nodebox",
|
||||||
tiles = {"door_trapdoor.png"},
|
tiles = def.tiles,
|
||||||
|
inventory_image = def.inventory_image,
|
||||||
|
wield_image = def.wield_image,
|
||||||
is_ground_content = false,
|
is_ground_content = false,
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
stack_max = 64,
|
stack_max = 64,
|
||||||
paramtype2 = "facedir",
|
paramtype2 = "facedir",
|
||||||
groups = {snappy=1,choppy=2,oddly_breakable_by_hand=2,mesecon_effector_on=1,door=2},
|
groups = def.groups,
|
||||||
sounds = mcl_sounds.node_sound_wood_defaults(),
|
sounds = def.sounds,
|
||||||
drop = "doors:trapdoor",
|
|
||||||
node_box = {
|
node_box = {
|
||||||
type = "fixed",
|
type = "fixed",
|
||||||
fixed = {
|
fixed = {
|
||||||
{-8/16, -8/16, -8/16, -5/16, -6/16, 8/16},--left
|
{-8/16, -8/16, -8/16, 8/16, -6/16, 8/16},},
|
||||||
{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
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
on_creation = function(pos)
|
on_creation = function(pos)
|
||||||
state = 0
|
state = 0
|
||||||
|
@ -541,17 +532,16 @@ minetest.register_node("doors:trapdoor", {
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
minetest.register_node(name.."_open", {
|
||||||
minetest.register_node("doors:trapdoor_open", {
|
|
||||||
drawtype = "nodebox",
|
drawtype = "nodebox",
|
||||||
tiles = {"door_trapdoor.png"},
|
tiles = def.tiles,
|
||||||
is_ground_content = false,
|
is_ground_content = false,
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
paramtype2 = "facedir",
|
paramtype2 = "facedir",
|
||||||
pointable = true,
|
pointable = true,
|
||||||
groups = {snappy=1,choppy=2,oddly_breakable_by_hand=2,mesecon_effector_on=1,door=2},
|
groups = def.groups,
|
||||||
sounds = mcl_sounds.node_sound_wood_defaults(),
|
sounds = def.sounds,
|
||||||
drop = "doors:trapdoor",
|
drop = name,
|
||||||
node_box = {
|
node_box = {
|
||||||
type = "fixed",
|
type = "fixed",
|
||||||
fixed = {-0.5, -0.5, 0.4, 0.5, 0.5, 0.5}
|
fixed = {-0.5, -0.5, 0.4, 0.5, 0.5, 0.5}
|
||||||
|
@ -568,11 +558,18 @@ minetest.register_node("doors:trapdoor_open", {
|
||||||
punch(pos)
|
punch(pos)
|
||||||
end),
|
end),
|
||||||
}},
|
}},
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
doors:register_trapdoor("doors:trapdoor", {
|
||||||
|
description = "Wooden Trapdoor",
|
||||||
|
tiles = {"door_trapdoor.png"},
|
||||||
|
wield_image = "door_trapdoor.png",
|
||||||
|
groups = {snappy=1,choppy=2,oddly_breakable_by_hand=2,mesecon_effector_on=1,door=2},
|
||||||
|
sounds = mcl_sounds.node_sound_wood_defaults(),
|
||||||
|
})
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
output = 'doors:trapdoor 2',
|
output = 'doors:trapdoor 2',
|
||||||
|
@ -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