diff --git a/mods/doors/README.txt b/mods/doors/README.txt index f1d6ab24..146af8ed 100644 --- a/mods/doors/README.txt +++ b/mods/doors/README.txt @@ -1,9 +1,11 @@ Minetest 0.4 mod: doors ======================= +version: 1.3 License of source code: ----------------------- Copyright (C) 2012 PilzAdam +modified by BlockMen (added sounds, glassdoors[glass, obsidian glass], 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,34 @@ 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 +following Textures created by BlockMen (WTFPL): + door_trapdoor.png + door_obsidian_glass_side.png + +following textures created by celeron55 (CC BY-SA 3.0): + door_trapdoor_side.png + door_glass_a.png + door_glass_b.png + +following Textures created by PenguinDad (CC BY-SA 4.0): + door_glass.png + door_obsidian_glass.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 diff --git a/mods/doors/init.lua b/mods/doors/init.lua index e18da8eb..44e2aa44 100644 --- a/mods/doors/init.lua +++ b/mods/doors/init.lua @@ -15,10 +15,23 @@ 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) + local r1 = minetest.get_node({x=pos.x-1, y=pos.y, z=pos.z}) + local r2 = minetest.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 + if string.find(r1.name, "_1") or string.find(r2.name, "_1") then + return true + else + return false + end + end +end + function doors:register_door(name, def) def.groups.not_in_creative_inventory = 1 - local box = {{-0.5, -0.5, -0.5, 0.5, 0.5, -0.5+1.5/16}} + local box = {{-0.5, -0.5, -0.5, 0.5, 0.5, -0.5+1.5/16}} if not def.node_box_bottom then def.node_box_bottom = box @@ -104,10 +117,11 @@ function doors:register_door(name, def) local tt = def.tiles_top local tb = def.tiles_bottom - - local function after_dig_node(pos, name) - if minetest.get_node(pos).name == name then - minetest.remove_node(pos) + + local function after_dig_node(pos, name, digger) + local node = minetest.get_node(pos) + if node.name == name then + minetest.node_dig(pos, node, digger) end end @@ -118,11 +132,24 @@ function doors:register_door(name, def) end local p2 = minetest.get_node(pos).param2 p2 = params[p2+1] - + minetest.swap_node(pos, {name=replace_dir, param2=p2}) - + pos.y = pos.y-dir minetest.swap_node(pos, {name=replace, param2=p2}) + + local snd_1 = "_close" + local snd_2 = "_open" + if params[1] == 3 then + snd_1 = "_open" + snd_2 = "_close" + end + + if is_right(pos) then + minetest.sound_play("door"..snd_1, {pos = pos, gain = 0.3, max_hear_distance = 10}) + else + minetest.sound_play("door"..snd_2, {pos = pos, gain = 0.3, max_hear_distance = 10}) + end end local function check_player_priv(pos, player) @@ -149,26 +176,28 @@ function doors:register_door(name, def) fixed = def.selection_box_bottom }, groups = def.groups, - + after_dig_node = function(pos, oldnode, oldmetadata, digger) pos.y = pos.y+1 - after_dig_node(pos, name.."_t_1") + after_dig_node(pos, name.."_t_1", digger) end, - + 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}) end end, - + can_dig = check_player_priv, + sounds = def.sounds, + sunlight_propagates = def.sunlight }) minetest.register_node(name.."_t_1", { tiles = {tt[2], tt[2], tt[2], tt[2], tt[1], tt[1].."^[transformfx"}, paramtype = "light", paramtype2 = "facedir", - drop = name, + drop = "", drawtype = "nodebox", node_box = { type = "fixed", @@ -179,19 +208,21 @@ function doors:register_door(name, def) fixed = def.selection_box_top }, groups = def.groups, - + after_dig_node = function(pos, oldnode, oldmetadata, digger) pos.y = pos.y-1 - after_dig_node(pos, name.."_b_1") + after_dig_node(pos, name.."_b_1", digger) end, - + 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}) end end, - + can_dig = check_player_priv, + sounds = def.sounds, + sunlight_propagates = def.sunlight, }) minetest.register_node(name.."_b_2", { @@ -209,26 +240,28 @@ function doors:register_door(name, def) fixed = def.selection_box_bottom }, groups = def.groups, - + after_dig_node = function(pos, oldnode, oldmetadata, digger) pos.y = pos.y+1 - after_dig_node(pos, name.."_t_2") + after_dig_node(pos, name.."_t_2", digger) end, - + 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}) end end, - + can_dig = check_player_priv, + sounds = def.sounds, + sunlight_propagates = def.sunlight }) minetest.register_node(name.."_t_2", { tiles = {tt[2], tt[2], tt[2], tt[2], tt[1].."^[transformfx", tt[1]}, paramtype = "light", paramtype2 = "facedir", - drop = name, + drop = "", drawtype = "nodebox", node_box = { type = "fixed", @@ -239,20 +272,23 @@ function doors:register_door(name, def) fixed = def.selection_box_top }, groups = def.groups, - + after_dig_node = function(pos, oldnode, oldmetadata, digger) pos.y = pos.y-1 - after_dig_node(pos, name.."_b_2") + after_dig_node(pos, name.."_b_2", digger) end, - + 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}) end end, - + can_dig = check_player_priv, + sounds = def.sounds, + sunlight_propagates = def.sunlight }) + end doors:register_door("doors:door_wood", { @@ -261,6 +297,8 @@ doors:register_door("doors:door_wood", { groups = {snappy=1,choppy=2,oddly_breakable_by_hand=2,flammable=2,door=1}, tiles_bottom = {"door_wood_b.png", "door_brown.png"}, tiles_top = {"door_wood_a.png", "door_brown.png"}, + sounds = default.node_sound_wood_defaults(), + sunlight = false, }) minetest.register_craft({ @@ -279,6 +317,8 @@ doors:register_door("doors:door_steel", { tiles_bottom = {"door_steel_b.png", "door_grey.png"}, tiles_top = {"door_steel_a.png", "door_grey.png"}, only_placer_can_open = true, + sounds = default.node_sound_wood_defaults(), + sunlight = false, }) minetest.register_craft({ @@ -290,7 +330,125 @@ minetest.register_craft({ } }) -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") +doors:register_door("doors:door_glass", { + description = "Glass Door", + inventory_image = "door_glass.png", + groups = {snappy=1,cracky=1,oddly_breakable_by_hand=3,door=1}, + tiles_bottom = {"door_glass_b.png", "door_glass_side.png"}, + tiles_top = {"door_glass_a.png", "door_glass_side.png"}, + sounds = default.node_sound_glass_defaults(), + sunlight = true, +}) + +minetest.register_craft({ + output = "doors:door_glass", + recipe = { + {"default:glass", "default:glass"}, + {"default:glass", "default:glass"}, + {"default:glass", "default:glass"} + } +}) + +doors:register_door("doors:door_obsidian_glass", { + description = "Obsidian Glass Door", + inventory_image = "door_obsidian_glass.png", + groups = {snappy=1,cracky=1,oddly_breakable_by_hand=3,door=1}, + tiles_bottom = {"door_obsidian_glass_b.png", "door_obsidian_glass_side.png"}, + tiles_top = {"door_obsidian_glass_b.png", "door_obsidian_glass_side.png"}, + sounds = default.node_sound_glass_defaults(), + sunlight = true, +}) + +minetest.register_craft({ + output = "doors:door_obsidian_glass", + recipe = { + {"default:obsidian_glass", "default:obsidian_glass"}, + {"default:obsidian_glass", "default:obsidian_glass"}, + {"default:obsidian_glass", "default:obsidian_glass"} + } +}) + + +----trapdoor---- + +local function update_door(pos, node) + minetest.set_node(pos, node) +end + +local function punch(pos) + local meta = minetest.get_meta(pos) + local state = meta:get_int("state") + local me = minetest.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", {pos = pos, 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", {pos = pos, 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", "door_trapdoor_side.png", "door_trapdoor_side.png", "door_trapdoor_side.png", "door_trapdoor_side.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 = {"door_trapdoor_side.png", "door_trapdoor_side.png", "door_trapdoor_side.png", "door_trapdoor_side.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'}, + {'', '', ''}, + } +}) diff --git a/mods/doors/sounds/door_close.ogg b/mods/doors/sounds/door_close.ogg new file mode 100644 index 00000000..a39452ba Binary files /dev/null and b/mods/doors/sounds/door_close.ogg differ diff --git a/mods/doors/sounds/door_open.ogg b/mods/doors/sounds/door_open.ogg new file mode 100644 index 00000000..7ec7f480 Binary files /dev/null and b/mods/doors/sounds/door_open.ogg differ diff --git a/mods/doors/textures/door_brown.png b/mods/doors/textures/door_brown.png index 5e6f2118..02173db5 100644 Binary files a/mods/doors/textures/door_brown.png and b/mods/doors/textures/door_brown.png differ diff --git a/mods/doors/textures/door_glass.png b/mods/doors/textures/door_glass.png new file mode 100644 index 00000000..6e381618 Binary files /dev/null and b/mods/doors/textures/door_glass.png differ diff --git a/mods/doors/textures/door_glass_a.png b/mods/doors/textures/door_glass_a.png new file mode 100644 index 00000000..ade0196f Binary files /dev/null and b/mods/doors/textures/door_glass_a.png differ diff --git a/mods/doors/textures/door_glass_b.png b/mods/doors/textures/door_glass_b.png new file mode 100644 index 00000000..ade0196f Binary files /dev/null and b/mods/doors/textures/door_glass_b.png differ diff --git a/mods/doors/textures/door_glass_side.png b/mods/doors/textures/door_glass_side.png new file mode 100644 index 00000000..871ad9d0 Binary files /dev/null and b/mods/doors/textures/door_glass_side.png differ diff --git a/mods/doors/textures/door_grey.png b/mods/doors/textures/door_grey.png index 7d95c226..aa01458c 100644 Binary files a/mods/doors/textures/door_grey.png and b/mods/doors/textures/door_grey.png differ diff --git a/mods/doors/textures/door_obsidian_glass.png b/mods/doors/textures/door_obsidian_glass.png new file mode 100644 index 00000000..d21c0126 Binary files /dev/null and b/mods/doors/textures/door_obsidian_glass.png differ diff --git a/mods/doors/textures/door_obsidian_glass_a.png b/mods/doors/textures/door_obsidian_glass_a.png new file mode 100644 index 00000000..42311be8 Binary files /dev/null and b/mods/doors/textures/door_obsidian_glass_a.png differ diff --git a/mods/doors/textures/door_obsidian_glass_b.png b/mods/doors/textures/door_obsidian_glass_b.png new file mode 100644 index 00000000..42311be8 Binary files /dev/null and b/mods/doors/textures/door_obsidian_glass_b.png differ diff --git a/mods/doors/textures/door_obsidian_glass_side.png b/mods/doors/textures/door_obsidian_glass_side.png new file mode 100644 index 00000000..d355a8ac Binary files /dev/null and b/mods/doors/textures/door_obsidian_glass_side.png differ diff --git a/mods/doors/textures/door_steel.png b/mods/doors/textures/door_steel.png index fed1794c..27e40302 100644 Binary files a/mods/doors/textures/door_steel.png and b/mods/doors/textures/door_steel.png differ diff --git a/mods/doors/textures/door_steel_a.png b/mods/doors/textures/door_steel_a.png index 77e3bc70..49604ce2 100644 Binary files a/mods/doors/textures/door_steel_a.png and b/mods/doors/textures/door_steel_a.png differ diff --git a/mods/doors/textures/door_steel_b.png b/mods/doors/textures/door_steel_b.png index 450f35fb..98b0d90b 100644 Binary files a/mods/doors/textures/door_steel_b.png and b/mods/doors/textures/door_steel_b.png differ diff --git a/mods/doors/textures/door_trapdoor.png b/mods/doors/textures/door_trapdoor.png new file mode 100644 index 00000000..8baac7a3 Binary files /dev/null and b/mods/doors/textures/door_trapdoor.png differ diff --git a/mods/doors/textures/door_trapdoor_side.png b/mods/doors/textures/door_trapdoor_side.png new file mode 100644 index 00000000..f81ff3d6 Binary files /dev/null and b/mods/doors/textures/door_trapdoor_side.png differ diff --git a/mods/doors/textures/door_wood.png b/mods/doors/textures/door_wood.png index 2b2136cb..120fc982 100644 Binary files a/mods/doors/textures/door_wood.png and b/mods/doors/textures/door_wood.png differ diff --git a/mods/doors/textures/door_wood_a.png b/mods/doors/textures/door_wood_a.png index adb4a1ec..1617b659 100644 Binary files a/mods/doors/textures/door_wood_a.png and b/mods/doors/textures/door_wood_a.png differ diff --git a/mods/doors/textures/door_wood_b.png b/mods/doors/textures/door_wood_b.png index c2716efa..80d43151 100644 Binary files a/mods/doors/textures/door_wood_b.png and b/mods/doors/textures/door_wood_b.png differ