From d9787c39d835aa18f727ffc4c732c52508f721d3 Mon Sep 17 00:00:00 2001 From: Jordan Snelling Date: Sun, 7 Oct 2012 10:43:16 +0100 Subject: [PATCH] add the actual mod this time and update readme with license info --- README.txt | 7 +- xdoors2/depends.txt | 1 + xdoors2/init.lua | 148 ++++++++++++++++++++++++++ xdoors2/textures/xdoors2_bottom.png | Bin 0 -> 109 bytes xdoors2/textures/xdoors2_bottom_1.png | Bin 0 -> 189 bytes xdoors2/textures/xdoors2_bottom_2.png | Bin 0 -> 187 bytes xdoors2/textures/xdoors2_door.png | Bin 0 -> 166 bytes xdoors2/textures/xdoors2_side.png | Bin 0 -> 109 bytes xdoors2/textures/xdoors2_top.png | Bin 0 -> 109 bytes xdoors2/textures/xdoors2_top_1.png | Bin 0 -> 202 bytes xdoors2/textures/xdoors2_top_2.png | Bin 0 -> 208 bytes 11 files changed, 155 insertions(+), 1 deletion(-) create mode 100644 xdoors2/depends.txt create mode 100644 xdoors2/init.lua create mode 100644 xdoors2/textures/xdoors2_bottom.png create mode 100644 xdoors2/textures/xdoors2_bottom_1.png create mode 100644 xdoors2/textures/xdoors2_bottom_2.png create mode 100644 xdoors2/textures/xdoors2_door.png create mode 100644 xdoors2/textures/xdoors2_side.png create mode 100644 xdoors2/textures/xdoors2_top.png create mode 100644 xdoors2/textures/xdoors2_top_1.png create mode 100644 xdoors2/textures/xdoors2_top_2.png diff --git a/README.txt b/README.txt index 877d6df..717ee12 100644 --- a/README.txt +++ b/README.txt @@ -1,3 +1,8 @@ xDoors2 is a fork the thexyz's mod; xDoors2. -Code is changed upto a certain degree; thus allowing any type of alpha channel, much like the Minecraft doors. \ No newline at end of file +Code is changed upto a certain degree; thus allowing any type of alpha channel, much like the Minecraft doors. + +License: + +Code license: WTFPL +Texture license: same as default doors textures (CC BY-SA 3.0) \ No newline at end of file diff --git a/xdoors2/depends.txt b/xdoors2/depends.txt new file mode 100644 index 0000000..4ad96d5 --- /dev/null +++ b/xdoors2/depends.txt @@ -0,0 +1 @@ +default diff --git a/xdoors2/init.lua b/xdoors2/init.lua new file mode 100644 index 0000000..9a7c6a4 --- /dev/null +++ b/xdoors2/init.lua @@ -0,0 +1,148 @@ +-- xDoors² mod by xyz + +-- remove default doors (or left/right version) and drop new doors +local REMOVE_OTHER_DOORS = false + +local door_bottom = {-0.5, -0.5, -0.5, 0.5, 0.5, -0.4} +local door_top = {-0.5, -0.5, -0.5, 0.5, 0.5, -0.4} + +local is_top = function(name) + return name:sub(14, 14) == "t" +end + +local xdoors2_transform = function(pos, node) + if is_top(node.name) then + pos = {x = pos.x, y = pos.y - 1, z = pos.z} + end + local t = 3 - node.name:sub(-1) + local p2 = 0 + if t == 2 then + p2 = (node.param2 + 1) % 4 + else + p2 = (node.param2 + 3) % 4 + end + minetest.env:add_node(pos, {name = "xdoors2:door_bottom_"..t, param2 = p2}) + minetest.env:add_node({x = pos.x, y = pos.y + 1, z = pos.z}, {name = "xdoors2:door_top_"..t, param2 = p2}) +end + +local xdoors2_destruct = function(pos, oldnode) + if is_top(oldnode.name) then + pos = {x = pos.x, y = pos.y - 1, z = pos.z} + end + minetest.env:remove_node(pos) + minetest.env:remove_node({x = pos.x, y = pos.y + 1, z = pos.z}) +end + +for i = 1, 2 do + minetest.register_node("xdoors2:door_top_"..i, { + tile_images = {"xdoors2_side.png", "xdoors2_side.png", "xdoors2_top.png", "xdoors2_bottom.png", "xdoors2_top_"..(3 - i)..".png", "xdoors2_top_"..i..".png"}, + paramtype = "light", + paramtype2 = "facedir", + drawtype = "nodebox", + drop = "xdoors2:door", + groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2}, + node_box = { + type = "fixed", + fixed = door_top + }, + selection_box = { + type = "fixed", + fixed = door_bottom + }, + on_punch = xdoors2_transform, + after_dig_node = xdoors2_destruct + }) + minetest.register_node("xdoors2:door_bottom_"..i, { + tile_images = {"xdoors2_side.png", "xdoors2_side.png", "xdoors2_top.png", "xdoors2_bottom.png", "xdoors2_bottom_"..(3 - i)..".png", "xdoors2_bottom_"..i..".png"}, + paramtype = "light", + paramtype2 = "facedir", + drawtype = "nodebox", + drop = "xdoors2:door", + groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2}, + node_box = { + type = "fixed", + fixed = door_bottom + }, + selection_box = { + type = "fixed", + fixed = door_bottom + }, + on_punch = xdoors2_transform, + after_dig_node = xdoors2_destruct + }) +end + +local delta = { + {x = -1, z = 0}, + {x = 0, z = 1}, + {x = 1, z = 0}, + {x = 0, z = -1} +} + +minetest.register_node("xdoors2:door", { + description = "Wooden Door", + node_placement_prediction = "", + inventory_image = 'xdoors2_door.png', + wield_image = 'xdoors2_door.png', + stack_max = 1, + on_place = function(itemstack, placer, pointed_thing) + local above = pointed_thing.above + + -- there should be 2 empty nodes + if minetest.env:get_node({x = above.x, y = above.y + 1, z = above.z}).name ~= "air" then + return itemstack + end + + local fdir = 0 + local placer_pos = placer:getpos() + if placer_pos then + dir = { + x = above.x - placer_pos.x, + y = above.y - placer_pos.y, + z = above.z - placer_pos.z + } + fdir = minetest.dir_to_facedir(dir) + end + + local t = 1 + local another_door = minetest.env:get_node({x = above.x + delta[fdir + 1].x, y = above.y, z = above.z + delta[fdir + 1].z}) + if (another_door.name:sub(-1) == "1" and another_door.param2 == fdir) + or (another_door.name:sub(-1) == "2" and another_door.param2 == (fdir + 1) % 4) then + t = 2 + end + + minetest.env:add_node(above, {name = "xdoors2:door_bottom_"..t, param2 = fdir}) + minetest.env:add_node({x = above.x, y = above.y + 1, z = above.z}, {name = "xdoors2:door_top_"..t, param2 = fdir}) + return ItemStack("") + end +}) + +minetest.register_craft({ + output = 'xdoors2:door', + recipe = { + { 'default:wood', 'default:wood', '' }, + { 'default:wood', 'default:wood', '' }, + { 'default:wood', 'default:wood', '' }, + }, +}) + +if REMOVE_OTHER_DOORS then + minetest.register_abm({ + nodenames = {"doors:door_wood_a_c", "doors:door_wood_b_c", "doors:door_wood_a_o", "doors:door_wood_b_o", + "doors:door_wood_right_a_c", "doors:door_wood_right_b_c", "doors:door_wood_right_a_o", "doors:door_wood_right_b_o", + "doors:door_wood_left_a_c", "doors:door_wood_left_b_c", "doors:door_wood_left_a_o", "doors:door_wood_left_b_o", + "xdoors:door_1_1", "xdoors:door_1_2", "xdoors:door_2_1", "xdoors:door_2_2", + "xdoors:door_3_1", "xdoors:door_3_2", "xdoors:door_4_1", "xdoors:door_4_2"}, + interval = 0.1, + chance = 1, + action = function(pos, node) + minetest.env:remove_node(pos) + if node.name:find("_b") ~= nil or node.name:find("xdoors:door") ~= nil then + minetest.env:add_item(pos, "xdoors2:door") + end + end + }) + minetest.register_alias("doors:door_wood_right", "xdoors2:door") + minetest.register_alias("doors:door_wood_left", "xdoors2:door") + minetest.register_alias("doors:door_wood", "xdoors2:door") +end diff --git a/xdoors2/textures/xdoors2_bottom.png b/xdoors2/textures/xdoors2_bottom.png new file mode 100644 index 0000000000000000000000000000000000000000..15ce4bd23717fb89a7f70901c87d2352186b196e GIT binary patch literal 109 zcmeAS@N?(olHy`uVBq!ia0vp^j3CUx1SBVv2j2ryoCO|{#S9GG!XV7ZFl&wkP>{XE z)7O>#4hNTrCbL1S#2TOwkEe@c2*>qg4c;kC3{3J256?-yx&stv@O1TaS?83{1OV&H B78(Em literal 0 HcmV?d00001 diff --git a/xdoors2/textures/xdoors2_bottom_1.png b/xdoors2/textures/xdoors2_bottom_1.png new file mode 100644 index 0000000000000000000000000000000000000000..5e7026c8218e04c787cfec98e4b62556c136bf4b GIT binary patch literal 189 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61SBU+%rFB|oCO|{#S9GG!XV7ZFl&wkP>{XE z)7O>#4hNTrl1cWNlnkIyjHioZh{pM39o{KbU*@$k>RZ%3wPa>)UfTEM@bdLDB|KPk zj%aMUGSTJwhYv5an{GW>>Kd5S@S%{=@}PbHJ!1m{g9&fi19?p@9%zy=RmqqzU98nb gB~Yrv)1!cap-4(JJj$l%8_*sGPgg&ebxsLQ08jQh!T{XE z)7O>#4hNTrnqpF|YdcUV%G1R$MB{w24)2tzFY})MnEITDhi97AB%X?chnKIPDdEAQ zBhahMj%MB@5x%w$tLz>g`#6KP+CQ)^OA#) cQxh}8t$U*3Ppa=P0@}jh>FVdQ&MBb@0FwnfI{*Lx literal 0 HcmV?d00001 diff --git a/xdoors2/textures/xdoors2_door.png b/xdoors2/textures/xdoors2_door.png new file mode 100644 index 0000000000000000000000000000000000000000..120fc982f7aeb151b2c014678b205072b2b20907 GIT binary patch literal 166 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|5{XE z)7O>#4hNTrhQTyHkKaHc9#0p?5RU7~8oX1O7?|W49-fnYbq6TU;OXk;vd$@?2>=ZL B7W4oB literal 0 HcmV?d00001 diff --git a/xdoors2/textures/xdoors2_top.png b/xdoors2/textures/xdoors2_top.png new file mode 100644 index 0000000000000000000000000000000000000000..2009fb9915a64c1551b79bcf4469af27f893afee GIT binary patch literal 109 zcmeAS@N?(olHy`uVBq!ia0vp^j3CUx1SBVv2j2ryoCO|{#S9GG!XV7ZFl&wkP>{XE z)7O>#4hNTrhUNQ7AL4;RJf1F&Asp9}HF&2mF)+z9JUl1)>JCtx!PC{xWt~$(696d~ B7p4FJ literal 0 HcmV?d00001 diff --git a/xdoors2/textures/xdoors2_top_1.png b/xdoors2/textures/xdoors2_top_1.png new file mode 100644 index 0000000000000000000000000000000000000000..b678ae2bc544ad2ced1df3dd5a343c3dab9d9f5c GIT binary patch literal 202 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|*pj^6T^Rm@ z;DWu&Cj&(|3p^r=85p>QL70(Y)*K0-AbW|YuPgfNY19*{oJbT)p+A8V-& q6RsnQ5^TrU+oW66J++*}&v5;maLVLoCs}}|GI+ZBxvXQL70(Y)*K0-AbW|YuPgf;nn~c)B=-Se#DY z67cj-{%YkD4tfcR2?+@mU*@&yoGogqmzW`;!Ez$ZIBDYle)l