Add sound to doors, add glass door and trapdoor

This commit is contained in:
BlockMen 2013-03-18 11:55:37 +01:00
parent 35de89c091
commit 458d45a2b3
6 changed files with 159 additions and 3 deletions

View File

@ -1,9 +1,11 @@
Minetest 0.4 mod: doors
=======================
version: 1.2.2
License of source code:
-----------------------
Copyright (C) 2012 PilzAdam
modified by BlockMen (added sounds, glassdoor, trapdoor)
This program is free software. It comes without any warranty, to
the extent permitted by applicable law. You can redistribute it
@ -11,13 +13,25 @@ and/or modify it under the terms of the Do What The Fuck You Want
To Public License, Version 2, as published by Sam Hocevar. See
http://sam.zoy.org/wtfpl/COPYING for more details.
License of media (textures and sounds)
License of textures
--------------------------------------
Textures created by Fernando Zapata (CC BY-SA 3.0):
following Textures created by Fernando Zapata (CC BY-SA 3.0):
door_wood.png
door_wood_a.png
door_wood_a_r.png
door_wood_b.png
door_wood_b_r.png
All other textures (created by PilzAdam): WTFPL
following Textures created by BlockMen (WTFPL):
door_glass.png
door_trapdoor.png
All other textures created by PilzAdam (WTFPL)
License of sounds
--------------------------------------
Opening-Sound created by CGEffex (CC BY 3.0), modified by BlockMen
door_open.ogg
Closing-Sound created by bennstir (CC BY 3.0)
door_close.ogg

View File

@ -15,6 +15,17 @@ doors = {}
-- selection_box_top
-- only_placer_can_open: if true only the player who placed the door can
-- open it
local function is_right(pos, clicker)
local r1 = minetest.env:get_node({x=pos.x+1, y=pos.y, z=pos.z})
local r2 = minetest.env:get_node({x=pos.x, y=pos.y, z=pos.z+1})
if string.find(r1.name, "door_") or string.find(r2.name, "door_") then
return false
else
return true
end
end
function doors:register_door(name, def)
def.groups.not_in_creative_inventory = 1
@ -156,6 +167,11 @@ function doors:register_door(name, def)
on_rightclick = function(pos, node, clicker)
if check_player_priv(pos, clicker) then
on_rightclick(pos, 1, name.."_t_1", name.."_b_2", name.."_t_2", {1,2,3,0})
if is_right(pos, clicker) then
minetest.sound_play("door_close", {gain = 0.3, max_hear_distance = 10})
else
minetest.sound_play("door_open", {gain = 0.3, max_hear_distance = 10})
end
end
end,
@ -186,6 +202,11 @@ function doors:register_door(name, def)
on_rightclick = function(pos, node, clicker)
if check_player_priv(pos, clicker) then
on_rightclick(pos, -1, name.."_b_1", name.."_t_2", name.."_b_2", {1,2,3,0})
if is_right(pos, clicker) then
minetest.sound_play("door_close", {gain = 0.3, max_hear_distance = 10})
else
minetest.sound_play("door_open", {gain = 0.3, max_hear_distance = 10})
end
end
end,
@ -216,6 +237,11 @@ function doors:register_door(name, def)
on_rightclick = function(pos, node, clicker)
if check_player_priv(pos, clicker) then
on_rightclick(pos, 1, name.."_t_2", name.."_b_1", name.."_t_1", {3,0,1,2})
if is_right(pos, clicker) then
minetest.sound_play("door_open", {gain = 0.3, max_hear_distance = 10})
else
minetest.sound_play("door_close", {gain = 0.3, max_hear_distance = 10})
end
end
end,
@ -246,6 +272,11 @@ function doors:register_door(name, def)
on_rightclick = function(pos, node, clicker)
if check_player_priv(pos, clicker) then
on_rightclick(pos, -1, name.."_b_2", name.."_t_1", name.."_b_1", {3,0,1,2})
if is_right(pos, clicker) then
minetest.sound_play("door_open", {gain = 0.3, max_hear_distance = 10})
else
minetest.sound_play("door_close", {gain = 0.3, max_hear_distance = 10})
end
end
end,
@ -289,7 +320,118 @@ minetest.register_craft({
}
})
doors:register_door("doors:door_glass", {
description = "Glass Door",
inventory_image = "door_glass.png",
groups = {snappy=1,cracky=1,oddly_breakable_by_hand=2,door=1},
tiles_bottom = {"default_glass.png", "door_grey.png"},
tiles_top = {"default_glass.png", "door_grey.png"},
})
minetest.register_craft({
output = "doors:door_glass",
recipe = {
{"default:glass", "default:glass"},
{"default:glass", "default:glass"},
{"default:glass", "default:glass"}
}
})
minetest.register_alias("doors:door_wood_a_c", "doors:door_wood_t_1")
minetest.register_alias("doors:door_wood_a_o", "doors:door_wood_t_1")
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")
----trapdoor----
local me
local meta
local state = 0
local function update_door(pos, node)
minetest.env:set_node(pos, node)
end
local function punch(pos)
meta = minetest.env:get_meta(pos)
state = meta:get_int("state")
me = minetest.env:get_node(pos)
local tmp_node
local tmp_node2
oben = {x=pos.x, y=pos.y+1, z=pos.z}
if state == 1 then
state = 0
minetest.sound_play("door_close", {to_player = puncher, gain = 0.3, max_hear_distance = 10})
tmp_node = {name="doors:trapdoor", param1=me.param1, param2=me.param2}
else
state = 1
minetest.sound_play("door_open", {to_player = puncher, gain = 0.3, max_hear_distance = 10})
tmp_node = {name="doors:trapdoor_open", param1=me.param1, param2=me.param2}
end
update_door(pos, tmp_node)
meta:set_int("state", state)
end
minetest.register_node("doors:trapdoor", {
description = "Trapdoor",
inventory_image = "door_trapdoor.png",
drawtype = "nodebox",
tiles = {"door_trapdoor.png", "door_trapdoor.png", "default_wood.png", "default_wood.png", "default_wood.png", "default_wood.png"},
paramtype = "light",
paramtype2 = "facedir",
groups = {snappy=1,choppy=2,oddly_breakable_by_hand=2,flammable=2,door=1},
sounds = default.node_sound_wood_defaults(),
drop = "doors:trapdoor",
node_box = {
type = "fixed",
fixed = {-0.5, -0.5, -0.5, 0.5, -0.4, 0.5}
},
selection_box = {
type = "fixed",
fixed = {-0.5, -0.5, -0.5, 0.5, -0.4, 0.5}
},
on_creation = function(pos)
state = 0
end,
on_rightclick = function(pos, node, clicker)
punch(pos)
end,
})
minetest.register_node("doors:trapdoor_open", {
drawtype = "nodebox",
tiles = {"default_wood.png", "default_wood.png", "default_wood.png", "default_wood.png", "door_trapdoor.png", "door_trapdoor.png"},
paramtype = "light",
paramtype2 = "facedir",
pointable = true,
stack_max = 0,
groups = {snappy=1,choppy=2,oddly_breakable_by_hand=2,flammable=2,door=1},
sounds = default.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,
})
minetest.register_craft({
output = 'doors:trapdoor 2',
recipe = {
{'group:wood', 'group:wood', 'group:wood'},
{'group:wood', 'group:wood', 'group:wood'},
{'', '', ''},
}
})

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 589 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 390 B