From 2d63ed31ba3d36f757c9e0c1890523fd919aaf95 Mon Sep 17 00:00:00 2001 From: Thomas--S Date: Sat, 23 Jul 2016 08:28:02 +0200 Subject: [PATCH] Add trapdoors --- init.lua | 116 +++++++++++++++++- textures/ts_doors_base_trapdoor.png | Bin 0 -> 289 bytes textures/ts_doors_base_trapdoor_full.png | Bin 0 -> 266 bytes .../ts_doors_base_trapdoor_full_locked.png | Bin 0 -> 285 bytes textures/ts_doors_base_trapdoor_locked.png | Bin 0 -> 306 bytes 5 files changed, 110 insertions(+), 6 deletions(-) create mode 100644 textures/ts_doors_base_trapdoor.png create mode 100644 textures/ts_doors_base_trapdoor_full.png create mode 100644 textures/ts_doors_base_trapdoor_full_locked.png create mode 100644 textures/ts_doors_base_trapdoor_locked.png diff --git a/init.lua b/init.lua index 68ff9a6..9d87fd4 100755 --- a/init.lua +++ b/init.lua @@ -1,6 +1,32 @@ ts_doors = {} +local function copytable(orig) + local orig_type = type(orig) + local copy + if orig_type == 'table' then + copy = {} + for orig_key, orig_value in next, orig, nil do + copy[copytable(orig_key)] = copytable(orig_value) + end + setmetatable(copy, copytable(getmetatable(orig))) + else + copy = orig + end + return copy +end + +local function register_alias(name, convert_to) + minetest.register_alias(name , convert_to ) + minetest.register_alias(name .. "_a", convert_to .. "_a") + minetest.register_alias(name .. "_b", convert_to .. "_b") +end + function ts_doors.register_door(recipe, description, texture) + register_alias("doors:ts_door_" .. recipe:gsub(":", "_"), "ts_doors:door_" .. recipe:gsub(":", "_")) + register_alias("doors:ts_door_full_" .. recipe:gsub(":", "_"), "ts_doors:door_full_" .. recipe:gsub(":", "_")) + register_alias("doors:ts_door_locked_" .. recipe:gsub(":", "_"), "ts_doors:door_locked_" .. recipe:gsub(":", "_")) + register_alias("doors:ts_door_full_locked_" .. recipe:gsub(":", "_"), "ts_doors:door_full_locked_" .. recipe:gsub(":", "_")) + local groups = minetest.registered_nodes[recipe].groups local door_groups = {} for k,v in pairs(groups) do @@ -8,7 +34,10 @@ function ts_doors.register_door(recipe, description, texture) door_groups[k] = v end end - doors.register("ts_door_" .. recipe:gsub(":", "_"), { + + trapdoor_groups = copytable(door_groups) + + doors.register("ts_doors:door_" .. recipe:gsub(":", "_"), { tiles = {{ name = "[combine:32x38:0,0=" .. texture .. ":0,16=" .. texture .. ":0,32=" .. texture .. ":16,0=" .. texture .. ":16,16=" .. texture .. ":16,32=" .. texture .. "^[transformR270^[colorize:#fff:30^ts_doors_base.png^[noalpha^[makealpha:0,255,0", backface_culling = true }}, description = description .. " Door", inventory_image = "[combine:32x38:0,0=" .. texture .. ":0,16=" .. texture .. ":16,0=" .. texture .. ":16,16=" .. texture .. "^[transformR270^[colorize:#fff:30^ts_doors_base_inv.png^[noalpha^[makealpha:0,255,0", @@ -20,22 +49,55 @@ function ts_doors.register_door(recipe, description, texture) } }) - doors.register("ts_door_full_" .. recipe:gsub(":", "_"), { + doors.register("ts_doors:door_full_" .. recipe:gsub(":", "_"), { tiles = {{ name = "[combine:32x38:0,0=" .. texture .. ":0,16=" .. texture .. ":0,32=" .. texture .. ":16,0=" .. texture .. ":16,16=" .. texture .. ":16,32=" .. texture .. "^[transformR270^[colorize:#fff:30^ts_doors_base_full.png^[noalpha", backface_culling = true }}, description = description .. " Door", inventory_image = "[combine:32x38:0,0=" .. texture .. ":0,16=" .. texture .. ":16,0=" .. texture .. ":16,16=" .. texture .. "^[transformR270^[colorize:#fff:30^ts_doors_base_full_inv.png^[noalpha^[makealpha:0,255,0", groups = door_groups, recipe = { {recipe}, - {"doors:ts_door_" .. recipe:gsub(":", "_")}, + {"ts_doors:door_" .. recipe:gsub(":", "_")}, } }) + doors.register_trapdoor("ts_doors:trapdoor_" .. recipe:gsub(":", "_"), { + description = description .. " Trapdoor", + inventory_image = texture .. "^[transformR270^[colorize:#fff:30^ts_doors_base_trapdoor.png^[noalpha^[makealpha:0,255,0", + wield_image = texture .. "^[transformR270^[colorize:#fff:30^ts_doors_base_trapdoor.png^[noalpha^[makealpha:0,255,0", + tile_front = texture .. "^[transformR270^[colorize:#fff:30^ts_doors_base_trapdoor.png^[noalpha^[makealpha:0,255,0", + tile_side = texture .. "^[colorize:#fff:30", + groups = trapdoor_groups, + }) + doors.register_trapdoor("ts_doors:trapdoor_full_" .. recipe:gsub(":", "_"), { + description = description .. " Trapdoor", + inventory_image = texture .. "^[transformR270^[colorize:#fff:30^ts_doors_base_trapdoor_full.png^[noalpha", + wield_image = texture .. "^[transformR270^[colorize:#fff:30^ts_doors_base_trapdoor_full.png^[noalpha", + tile_front = texture .. "^[transformR270^[colorize:#fff:30^ts_doors_base_trapdoor_full.png^[noalpha", + tile_side = texture .. "^[colorize:#fff:30", + groups = trapdoor_groups, + }) + + minetest.register_craft({ + output = "ts_doors:trapdoor_" .. recipe:gsub(":", "_"), + recipe = { + {recipe, recipe}, + {recipe, recipe}, + } + }) + + minetest.register_craft({ + output = "ts_doors:trapdoor_full_" .. recipe:gsub(":", "_"), + recipe = { + {recipe}, + {"ts_doors:trapdoor_" .. recipe:gsub(":", "_")}, + } + }) door_groups.level = 2 + trapdoor_groups.level = 2 - doors.register("ts_door_locked_" .. recipe:gsub(":", "_"), { + doors.register("ts_doors:door_locked_" .. recipe:gsub(":", "_"), { tiles = {{ name = "[combine:32x38:0,0=" .. texture .. ":0,16=" .. texture .. ":0,32=" .. texture .. ":16,0=" .. texture .. ":16,16=" .. texture .. ":16,32=" .. texture .. "^[transformR270^[colorize:#fff:30^ts_doors_base_locked.png^[noalpha^[makealpha:0,255,0", backface_culling = true }}, description = description .. " Locked Door", inventory_image = "[combine:32x38:0,0=" .. texture .. ":0,16=" .. texture .. ":16,0=" .. texture .. ":16,16=" .. texture .. "^[transformR270^[colorize:#fff:30^ts_doors_base_locked_inv.png^[noalpha^[makealpha:0,255,0", @@ -50,7 +112,7 @@ function ts_doors.register_door(recipe, description, texture) } }) - doors.register("ts_door_full_locked_" .. recipe:gsub(":", "_"), { + doors.register("ts_doors:door_full_locked_" .. recipe:gsub(":", "_"), { tiles = {{ name = "[combine:32x38:0,0=" .. texture .. ":0,16=" .. texture .. ":0,32=" .. texture .. ":16,0=" .. texture .. ":16,16=" .. texture .. ":16,32=" .. texture .. "^[transformR270^[colorize:#fff:30^ts_doors_base_full_locked.png^[noalpha", backface_culling = true }}, description = description .. " Locked Door", inventory_image = "[combine:32x38:0,0=" .. texture .. ":0,16=" .. texture .. ":16,0=" .. texture .. ":16,16=" .. texture .. "^[transformR270^[colorize:#fff:30^ts_doors_base_full_locked_inv.png^[noalpha^[makealpha:0,255,0", @@ -60,7 +122,49 @@ function ts_doors.register_door(recipe, description, texture) sound_close = "doors_steel_door_close", recipe = { {recipe}, - {"doors:ts_door_locked_" .. recipe:gsub(":", "_")}, + {"ts_doors:door_locked_" .. recipe:gsub(":", "_")}, + } + }) + + doors.register_trapdoor("ts_doors:trapdoor_locked_" .. recipe:gsub(":", "_"), { + description = description .. " Locked Trapdoor", + inventory_image = texture .. "^[transformR270^[colorize:#fff:30^ts_doors_base_trapdoor_locked.png^[noalpha^[makealpha:0,255,0", + wield_image = texture .. "^[transformR270^[colorize:#fff:30^ts_doors_base_trapdoor_locked.png^[noalpha^[makealpha:0,255,0", + tile_front = texture .. "^[transformR270^[colorize:#fff:30^ts_doors_base_trapdoor_locked.png^[noalpha^[makealpha:0,255,0", + tile_side = texture .. "^[colorize:#fff:30", + protected = true, + sounds = default.node_sound_stone_defaults(), + sound_open = "doors_steel_door_open", + sound_close = "doors_steel_door_close", + groups = trapdoor_groups + }) + + doors.register_trapdoor("ts_doors:trapdoor_full_locked_" .. recipe:gsub(":", "_"), { + description = description .. " Locked Trapdoor", + inventory_image = texture .. "^[transformR270^[colorize:#fff:30^ts_doors_base_trapdoor_full_locked.png^[noalpha", + wield_image = texture .. "^[transformR270^[colorize:#fff:30^ts_doors_base_trapdoor_full_locked.png^[noalpha", + tile_front = texture .. "^[transformR270^[colorize:#fff:30^ts_doors_base_trapdoor_full_locked.png^[noalpha", + tile_side = texture .. "^[colorize:#fff:30", + protected = true, + sounds = default.node_sound_stone_defaults(), + sound_open = "doors_steel_door_open", + sound_close = "doors_steel_door_close", + groups = trapdoor_groups + }) + + minetest.register_craft({ + output = "ts_doors:trapdoor_locked_" .. recipe:gsub(":", "_"), + recipe = { + {"default:steel_ingot"}, + {"ts_doors:trapdoor_" .. recipe:gsub(":", "_")}, + } + }) + + minetest.register_craft({ + output = "ts_doors:trapdoor_full_locked_" .. recipe:gsub(":", "_"), + recipe = { + {recipe}, + {"ts_doors:trapdoor_locked_" .. recipe:gsub(":", "_")}, } }) end diff --git a/textures/ts_doors_base_trapdoor.png b/textures/ts_doors_base_trapdoor.png new file mode 100644 index 0000000000000000000000000000000000000000..dcfe61d3a1b34887a3096a9754160fd92287556e GIT binary patch literal 289 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Y)RhkE)4%caKYZ?lYt_f1s;*b z3=G`DAk4@xYmNj^kiEpy*OmPNyAZ3q{-+1bAS2g#x;TbdoZdRgm+z2*Kx%}jt$Ve+{xU_wwcL$NPQj{t+|R!Irrj$!AX>5E6yt;gmv2_;Y};CLs`tJM z1H+8(%b#6MJ?i%H$<)o-Zz30o|KYRgTzT*J(Q|n-*X(R^o7j1^uyb3j&Ji2#T|5El z$)~peUoOZrRetVSu>-ad+{q@NC!~ZWFaio?h4 z$8V(CbiGkH{JO%>+tI9EXI*w-Y1BdXrIl~JKY3{#;N(z|VPJiC?DTHa_g9*!1y5x2r5tW_(Bl3VH=mHb|h!0!NtIRmeH{X z{|jq8xRw{XzBiTi_E!Ib{W*`P)Td_at1~2@S$O?X?CH$4bEC^RZM70QR?k-9iMGv{ ar@nf%rm9Ml%`c#<89ZJ6T-G@yGywnutZ8Wg literal 0 HcmV?d00001 diff --git a/textures/ts_doors_base_trapdoor_locked.png b/textures/ts_doors_base_trapdoor_locked.png new file mode 100644 index 0000000000000000000000000000000000000000..109220e68571c37ccfa2f5651fe3e152cfd6c940 GIT binary patch literal 306 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Y)RhkE)4%caKYZ?lYt_f1s;*b z3=G`DAk4@xYmNj^kiEpy*OmPNyC}aYyG7lt?LeXZo-U3d7N@sP_T_6<5NNgM?0mUs zwcO$68>!!84!yAa!g05-BW_KvXYeioL4n-hOUIjjHk!|@3}6s{aIlG4p>g@w$8+9? zUy?GfYgT5+SiZJKcVXb07`e2?+r*`Nw#VF=#J+RW%*T&TX9-T*+~jlOfVM^TWjnQ^ z&0L|g5~6z*=lz=>RS>jJYkM_I`E$vt_0RPzc1{#Npt+n?aPQk3N$dZb*|nw&UMusi xPHMLjy%IHhitM7CC0Donaxu~rtlu)x{F1e~N