Added Glass and Obsidian Glass door (doors mod)
authorPenguinDad <tamarok40@gmail.com>
Wed, 16 Apr 2014 14:31:30 +0000 (16:31 +0200)
committerBlockMen <nmuelll@web.de>
Sat, 5 Jul 2014 14:02:17 +0000 (16:02 +0200)
22 files changed:
mods/doors/README.txt
mods/doors/init.lua
mods/doors/sounds/door_close.ogg [new file with mode: 0644]
mods/doors/sounds/door_open.ogg [new file with mode: 0644]
mods/doors/textures/door_brown.png
mods/doors/textures/door_glass.png [new file with mode: 0644]
mods/doors/textures/door_glass_a.png [new file with mode: 0644]
mods/doors/textures/door_glass_b.png [new file with mode: 0644]
mods/doors/textures/door_glass_side.png [new file with mode: 0644]
mods/doors/textures/door_grey.png
mods/doors/textures/door_obsidian_glass.png [new file with mode: 0644]
mods/doors/textures/door_obsidian_glass_a.png [new file with mode: 0644]
mods/doors/textures/door_obsidian_glass_b.png [new file with mode: 0644]
mods/doors/textures/door_obsidian_glass_side.png [new file with mode: 0644]
mods/doors/textures/door_steel.png
mods/doors/textures/door_steel_a.png
mods/doors/textures/door_steel_b.png
mods/doors/textures/door_trapdoor.png [new file with mode: 0644]
mods/doors/textures/door_trapdoor_side.png [new file with mode: 0644]
mods/doors/textures/door_wood.png
mods/doors/textures/door_wood_a.png
mods/doors/textures/door_wood_b.png

index f1d6ab240e6fb34eb6e840b1dc2e1696702c6414..146af8ed16e8bf03737c30d994ccc1df902e1c11 100644 (file)
@@ -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
index e18da8eb1f9dcfc15dbe4f0fad0442da0ff0450c..44e2aa445ed5a7f1df52be3d4cc492dc909ccca4 100644 (file)
@@ -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 (file)
index 0000000..a39452b
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 (file)
index 0000000..7ec7f48
Binary files /dev/null and b/mods/doors/sounds/door_open.ogg differ
index 5e6f211836ff64d394b5bb7591b9d125bcfc54d8..02173db5f3547cd0d4c93542a638aa86c7a6f158 100644 (file)
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 (file)
index 0000000..6e38161
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 (file)
index 0000000..ade0196
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 (file)
index 0000000..ade0196
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 (file)
index 0000000..871ad9d
Binary files /dev/null and b/mods/doors/textures/door_glass_side.png differ
index 7d95c2269de1760ce4155cc234b77debe2481c86..aa01458c3718fac08003a3042338fc9a85f60118 100644 (file)
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 (file)
index 0000000..d21c012
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 (file)
index 0000000..42311be
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 (file)
index 0000000..42311be
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 (file)
index 0000000..d355a8a
Binary files /dev/null and b/mods/doors/textures/door_obsidian_glass_side.png differ
index fed1794c4c745c1e51847d3ade54cc8ba17e1bff..27e40302ab24e0fbae9f447e5cad0722ee20a247 100644 (file)
Binary files a/mods/doors/textures/door_steel.png and b/mods/doors/textures/door_steel.png differ
index 77e3bc70a8b7c2f4ed87a494677918cd7c70178a..49604ce27f5d6beb61946575d7e7419ee88d9812 100644 (file)
Binary files a/mods/doors/textures/door_steel_a.png and b/mods/doors/textures/door_steel_a.png differ
index 450f35fbc57864c683325b875a5ba91b84483ba1..98b0d90b348819ee0be69e2246bd152608a548a1 100644 (file)
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 (file)
index 0000000..8baac7a
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 (file)
index 0000000..f81ff3d
Binary files /dev/null and b/mods/doors/textures/door_trapdoor_side.png differ
index 2b2136cbcf71d000f0fa7a4fc87ef88f1bce8229..120fc982f7aeb151b2c014678b205072b2b20907 100644 (file)
Binary files a/mods/doors/textures/door_wood.png and b/mods/doors/textures/door_wood.png differ
index adb4a1ecd6150efdd134cb9fe160f40f92407836..1617b65938d2fca874f862977c4095a87264fcfb 100644 (file)
Binary files a/mods/doors/textures/door_wood_a.png and b/mods/doors/textures/door_wood_a.png differ
index c2716efa5520da8b0945c1c243447636b5f3e9a7..80d43151ca5e7f2c859354372348a5f24ed55387 100644 (file)
Binary files a/mods/doors/textures/door_wood_b.png and b/mods/doors/textures/door_wood_b.png differ