updated to work with 0.4.12
authortenplus1 <kinsellaja@yahoo.com>
Wed, 1 Apr 2015 10:13:07 +0000 (11:13 +0100)
committertenplus1 <kinsellaja@yahoo.com>
Wed, 1 Apr 2015 10:13:07 +0000 (11:13 +0100)
14 files changed:
README.md
init.lua
textures/door_brown.png [deleted file]
textures/door_grey.png [deleted file]
textures/door_steel.png [deleted file]
textures/door_steel_a.png [deleted file]
textures/door_steel_b.png [deleted file]
textures/door_wood.png [deleted file]
textures/door_wood_a.png [deleted file]
textures/door_wood_b.png [deleted file]
textures/moreblocks_circle_stone_bricks.png [new file with mode: 0644]
textures/protector_logo.png
textures/protector_side.png [deleted file]
textures/protector_top.png [deleted file]

index b731cf8..303740c 100644 (file)
--- a/README.md
+++ b/README.md
@@ -13,3 +13,4 @@ Released under WTFPL
 0.5 - Added protector.radius variable in init.lua (default: 5)
 0.6 - Added Protected Doors (wood and steel) and Protected Chest
 0.7 - Protected Chests now have "To Chest" and "To Inventory" buttons to copy contents across, also chests can be named
+0.8 - Updated to work with Minetest 0.4.12, simplified textures
\ No newline at end of file
index 1ff71d8..61aecc5 100644 (file)
--- a/init.lua
+++ b/init.lua
@@ -176,7 +176,7 @@ end
 
 minetest.register_node("protector:protect", {
        description = "Protection Block",
-       tiles = {"protector_top.png","protector_top.png","protector_side.png"},
+       tiles = {"moreblocks_circle_stone_bricks.png","moreblocks_circle_stone_bricks.png","moreblocks_circle_stone_bricks.png^protector_logo.png"},
        sounds = default.node_sound_stone_defaults(),
        groups = {dig_immediate=2},
        drawtype = "nodebox",
@@ -401,11 +401,11 @@ local function on_rightclick(pos, dir, check_name, replace, replace_dir, params)
        pos.y = pos.y-dir
        minetest.swap_node(pos, {name=replace, param2=p2})
 
-       local snd_1 = "door_close"
-       local snd_2 = "door_open" 
+       local snd_1 = "doors_door_close"
+       local snd_2 = "doors_door_open" 
        if params[1] == 3 then
-               snd_1 = "door_open"
-               snd_2 = "door_close"
+               snd_1 = "doors_door_open"
+               snd_2 = "doors_door_close"
        end
 
        if minetest.get_meta(pos):get_int("right") ~= 0 then
@@ -421,10 +421,10 @@ local name = "protector:door_wood"
 
 doors.register_door(name, {
        description = "Protected Wooden Door",
-       inventory_image = "door_wood.png^protector_logo.png",
+       inventory_image = "doors_wood.png^protector_logo.png",
        groups = {snappy=1,choppy=2,oddly_breakable_by_hand=2,flammable=2,door=1},
-       tiles_bottom = {"door_wood_b.png^protector_logo.png", "door_brown.png"},
-       tiles_top = {"door_wood_a.png", "door_brown.png"},
+       tiles_bottom = {"doors_wood_b.png^protector_logo.png", "doors_brown.png"},
+       tiles_top = {"doors_wood_a.png", "doors_brown.png"},
        sounds = default.node_sound_wood_defaults(),
        sunlight = false,
 })
@@ -483,10 +483,10 @@ local name = "protector:door_steel"
 
 doors.register_door(name, {
        description = "Protected Steel Door",
-       inventory_image = "door_steel.png^protector_logo.png",
+       inventory_image = "doors_steel.png^protector_logo.png",
        groups = {snappy=1,bendy=2,cracky=1,melty=2,level=2,door=1},
-       tiles_bottom = {"door_steel_b.png^protector_logo.png", "door_grey.png"},
-       tiles_top = {"door_steel_a.png", "door_grey.png"},
+       tiles_bottom = {"doors_steel_b.png^protector_logo.png", "doors_grey.png"},
+       tiles_top = {"doors_steel_a.png", "doors_grey.png"},
        sounds = default.node_sound_wood_defaults(),
        sunlight = false,
 })
@@ -539,23 +539,6 @@ minetest.register_craft({
        }
 })
 
-local function get_locked_chest_formspec(pos)
-       local spos = pos.x .. "," .. pos.y .. "," ..pos.z
-       local formspec =
-               "size[8,9]"..
-               default.gui_bg..
-               default.gui_bg_img..
-               default.gui_slots..
-               "list[nodemeta:".. spos .. ";main;0,0.3;8,4;]"..
-               "button[0,4.5;2,0.25;toup;To Chest]"..
-               "field[2.3,4.8;4,0.25;chestname;;]"..
-               "button[6,4.5;2,0.25;todn;To Inventory]"..
-               "list[current_player;main;0,5;8,1;]"..
-               "list[current_player;main;0,6.08;8,3;8]"..
-               default.get_hotbar_bg(0,5)
- return formspec
-end
-
 -- Protected Chest
 
 minetest.register_node("protector:chest", {
@@ -570,6 +553,7 @@ minetest.register_node("protector:chest", {
        on_construct = function(pos)
                local meta = minetest.get_meta(pos)
                meta:set_string("infotext", "Protected Chest")
+               meta:set_string("name", "")
                local inv = meta:get_inventory()
                inv:set_size("main", 8*4)
        end,
@@ -602,10 +586,22 @@ minetest.register_node("protector:chest", {
        on_rightclick = function(pos, node, clicker)
                local meta = minetest.get_meta(pos)
                if not minetest.is_protected(pos, clicker:get_player_name()) then
+
+               local spos = pos.x .. "," .. pos.y .. "," ..pos.z
+               local formspec = "size[8,9]"..
+                       default.gui_bg..default.gui_bg_img..default.gui_slots..
+                       "list[nodemeta:".. spos .. ";main;0,0.3;8,4;]"..
+                       "button[0,4.5;2,0.25;toup;To Chest]"..
+                       "field[2.3,4.8;4,0.25;chestname;;"..meta:get_string("name").."]"..
+                       "button[6,4.5;2,0.25;todn;To Inventory]"..
+                       "list[current_player;main;0,5;8,1;]"..
+                       "list[current_player;main;0,6.08;8,3;8]"..
+                       default.get_hotbar_bg(0,5)
+
                        minetest.show_formspec(
                                clicker:get_player_name(),
                                "protector:chest_"..minetest.pos_to_string(pos),
-                               get_locked_chest_formspec(pos)
+                               formspec
                        )
                end
        end,
@@ -654,6 +650,7 @@ minetest.register_on_player_receive_fields(function(player,formname,fields)
 
                        -- change chest infotext to display name
                        if fields.chestname ~= "" then
+                               meta:set_string("name", fields.chestname)
                                meta:set_string("infotext", "Protected Chest ("..fields.chestname..")")
                        else
                                meta:set_string("infotext", "Protected Chest")
diff --git a/textures/door_brown.png b/textures/door_brown.png
deleted file mode 100644 (file)
index 77f748d..0000000
Binary files a/textures/door_brown.png and /dev/null differ
diff --git a/textures/door_grey.png b/textures/door_grey.png
deleted file mode 100644 (file)
index 13665d2..0000000
Binary files a/textures/door_grey.png and /dev/null differ
diff --git a/textures/door_steel.png b/textures/door_steel.png
deleted file mode 100644 (file)
index 042a1bc..0000000
Binary files a/textures/door_steel.png and /dev/null differ
diff --git a/textures/door_steel_a.png b/textures/door_steel_a.png
deleted file mode 100644 (file)
index 515dafc..0000000
Binary files a/textures/door_steel_a.png and /dev/null differ
diff --git a/textures/door_steel_b.png b/textures/door_steel_b.png
deleted file mode 100644 (file)
index c1b75a4..0000000
Binary files a/textures/door_steel_b.png and /dev/null differ
diff --git a/textures/door_wood.png b/textures/door_wood.png
deleted file mode 100644 (file)
index d3a62ab..0000000
Binary files a/textures/door_wood.png and /dev/null differ
diff --git a/textures/door_wood_a.png b/textures/door_wood_a.png
deleted file mode 100644 (file)
index 0317b1f..0000000
Binary files a/textures/door_wood_a.png and /dev/null differ
diff --git a/textures/door_wood_b.png b/textures/door_wood_b.png
deleted file mode 100644 (file)
index f016933..0000000
Binary files a/textures/door_wood_b.png and /dev/null differ
diff --git a/textures/moreblocks_circle_stone_bricks.png b/textures/moreblocks_circle_stone_bricks.png
new file mode 100644 (file)
index 0000000..1782c00
Binary files /dev/null and b/textures/moreblocks_circle_stone_bricks.png differ
index 20c0b8e..c6f6f51 100644 (file)
Binary files a/textures/protector_logo.png and b/textures/protector_logo.png differ
diff --git a/textures/protector_side.png b/textures/protector_side.png
deleted file mode 100644 (file)
index 73ec762..0000000
Binary files a/textures/protector_side.png and /dev/null differ
diff --git a/textures/protector_top.png b/textures/protector_top.png
deleted file mode 100644 (file)
index a4bf3f8..0000000
Binary files a/textures/protector_top.png and /dev/null differ