From e9a7782c883a273492c9ce2e0a7a56881218f6b3 Mon Sep 17 00:00:00 2001 From: Auke Kok Date: Mon, 14 Dec 2015 23:35:14 -0800 Subject: [PATCH] Steel Trapdoor. Adds a steel trapdoor. Textures were painted from scratch, and inspired by the current Steel Door. Ownership on the trapdoor works as expected, and so does the crafting recipe. --- mods/doors/README.txt | 7 ++- mods/doors/init.lua | 54 +++++++++++++++++- mods/doors/textures/doors_trapdoor_steel.png | Bin 0 -> 153 bytes .../textures/doors_trapdoor_steel_side.png | Bin 0 -> 101 bytes 4 files changed, 58 insertions(+), 3 deletions(-) create mode 100644 mods/doors/textures/doors_trapdoor_steel.png create mode 100644 mods/doors/textures/doors_trapdoor_steel_side.png diff --git a/mods/doors/README.txt b/mods/doors/README.txt index 5ae63caf..c83720ce 100644 --- a/mods/doors/README.txt +++ b/mods/doors/README.txt @@ -6,6 +6,7 @@ License of source code: ----------------------- Copyright (C) 2012 PilzAdam modified by BlockMen (added sounds, glassdoors[glass, obsidian glass], trapdoor) +Steel trapdoor added by sofar. This program is free software. It comes without any warranty, to the extent permitted by applicable law. You can redistribute it @@ -30,11 +31,15 @@ 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 +Steel trapdoor textures by sofar (CC-BY-SA-3.0) + doors_trapdoor_steel.png + doors_trapdoor_steel_side.png + All other textures (created by PilzAdam): WTFPL diff --git a/mods/doors/init.lua b/mods/doors/init.lua index 6a5ee24f..eaf4986f 100644 --- a/mods/doors/init.lua +++ b/mods/doors/init.lua @@ -428,7 +428,19 @@ function doors.register_trapdoor(name, def) local name_closed = name local name_opened = name.."_open" - def.on_rightclick = function (pos, node) + local function check_player_priv(pos, player) + if not def.only_placer_can_open then + return true + end + local meta = minetest.get_meta(pos) + local pn = player:get_player_name() + return meta:get_string("doors_owner") == pn + end + + def.on_rightclick = function (pos, node, clicker, itemstack, pointed_thing) + if not check_player_priv(pos, clicker) then + return + end local newname = node.name == name_closed and name_opened or name_closed local sound = false if node.name == name_closed then sound = def.sound_open end @@ -436,7 +448,7 @@ function doors.register_trapdoor(name, def) if sound then minetest.sound_play(sound, {pos = pos, gain = 0.3, max_hear_distance = 10}) end - minetest.set_node(pos, {name = newname, param1 = node.param1, param2 = node.param2}) + minetest.swap_node(pos, {name = newname, param1 = node.param1, param2 = node.param2}) end def.on_rotate = minetest.get_modpath("screwdriver") and screwdriver.rotate_simple @@ -446,6 +458,21 @@ function doors.register_trapdoor(name, def) def.paramtype = "light" def.paramtype2 = "facedir" def.is_ground_content = false + def.can_dig = check_player_priv + + if def.only_placer_can_open then + def.after_place_node = function(pos, placer, itemstack, pointed_thing) + local pn = placer:get_player_name() + local meta = minetest.get_meta(pos) + meta:set_string("doors_owner", pn) + meta:set_string("infotext", "Owned by "..pn) + + if not minetest.setting_getbool("creative_mode") then + return true + end + return false + end + end local def_opened = table.copy(def) local def_closed = table.copy(def) @@ -492,6 +519,19 @@ doors.register_trapdoor("doors:trapdoor", { sound_close = "doors_door_close" }) +doors.register_trapdoor("doors:trapdoor_steel", { + description = "Steel Trapdoor", + inventory_image = "doors_trapdoor_steel.png", + wield_image = "doors_trapdoor_steel.png", + tile_front = "doors_trapdoor_steel.png", + tile_side = "doors_trapdoor_steel_side.png", + only_placer_can_open = true, + groups = {snappy=1, bendy=2, cracky=1, melty=2, level=2, door=1}, + sounds = default.node_sound_wood_defaults(), + sound_open = "doors_door_open", + sound_close = "doors_door_close" +}) + minetest.register_craft({ output = 'doors:trapdoor 2', recipe = { @@ -500,3 +540,13 @@ minetest.register_craft({ {'', '', ''}, } }) + +minetest.register_craft({ + output = 'doors:trapdoor_steel 2', + recipe = { + {'default:steel_ingot', 'default:steel_ingot', 'default:steel_ingot'}, + {'default:steel_ingot', 'default:steel_ingot', 'default:steel_ingot'}, + {'', '', ''}, + } +}) + diff --git a/mods/doors/textures/doors_trapdoor_steel.png b/mods/doors/textures/doors_trapdoor_steel.png new file mode 100644 index 0000000000000000000000000000000000000000..4ba507d61f4008580f5e9ec2fee3b276b36256d7 GIT binary patch literal 153 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!93?!50ihlx9JOMr-uBp1|+qZ8&ckbN1d-wjt z`Yr&9GnNGT1v5B2yO9RuSbMrShHzX@{=v_}vp#HX)X5JfCMJ^}a^7e0RC)As|4(zt zd26Fgg`I48XLE%dVw=<|oRFKqysoXSjfsILO+{5}-;qN=V;DSL{an^LB{Ts5zsE8* literal 0 HcmV?d00001 diff --git a/mods/doors/textures/doors_trapdoor_steel_side.png b/mods/doors/textures/doors_trapdoor_steel_side.png new file mode 100644 index 0000000000000000000000000000000000000000..44c4344b2b4f4ba16d9ea1427d94ad5abcff8ef3 GIT binary patch literal 101 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!93?!50ihlx9oB=)|uG_b7KX>ljy?ggsL_^Ji xg5sVojv*Y^lM@&k0~8V>SXl&^&Zzn`G3?nZ{*uYv`T|f1gQu&X%Q~loCIHdY8#e#| literal 0 HcmV?d00001