summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTenPlus1 <kinsellaja@yahoo.com>2016-06-05 12:06:59 +0100
committerTenPlus1 <kinsellaja@yahoo.com>2016-06-05 12:06:59 +0100
commitb0c2e6433f7e6b022b753eeb6e00452db09a797c (patch)
tree328db15234370f8d12ce1b51bb1bf42e86f96105
parent441a7a664627b89d1e38baf49e54a0f4bc016af1 (diff)
Tidy and tweak
-rw-r--r--admin.lua2
-rw-r--r--init.lua24
2 files changed, 14 insertions, 12 deletions
diff --git a/admin.lua b/admin.lua
index e48c0e4..7844d53 100644
--- a/admin.lua
+++ b/admin.lua
@@ -56,4 +56,4 @@ minetest.register_abm({
end
end
-}) \ No newline at end of file
+})
diff --git a/init.lua b/init.lua
index e284d1c..a04df4c 100644
--- a/init.lua
+++ b/init.lua
@@ -1,3 +1,4 @@
+
minetest.register_privilege("delprotect","Ignore player protection")
protector = {}
@@ -66,26 +67,26 @@ protector.generate_formspec = function(meta)
.. default.gui_slots
.. "label[2.5,0;-- Protector interface --]"
.. "label[0,1;PUNCH node to show protected area or USE for area check]"
- .. "label[0,2;Members: (type player name then press Enter to add)]"
+ .. "label[0,2;Members:]"
.. "button_exit[2.5,6.2;3,0.5;close_me;Close]"
local members = protector.get_member_list(meta)
local npp = 12 -- max users added onto protector list
local i = 0
- for _, member in pairs(members) do
+ for n = 1, #members do
if i < npp then
-- show username
formspec = formspec .. "button[" .. (i % 4 * 2)
.. "," .. math.floor(i / 4 + 3)
- .. ";1.5,.5;protector_member;" .. member .. "]"
+ .. ";1.5,.5;protector_member;" .. members[n] .. "]"
-- username remove button
.. "button[" .. (i % 4 * 2 + 1.25) .. ","
.. math.floor(i / 4 + 3)
- .. ";.75,.5;protector_del_member_" .. member .. ";X]"
+ .. ";.75,.5;protector_del_member_" .. members[n] .. ";X]"
end
i = i + 1
@@ -132,16 +133,16 @@ protector.can_dig = function(r, pos, digger, onlyowner, infolevel)
-- Find the protector nodes
- local positions = minetest.find_nodes_in_area(
+ local pos = minetest.find_nodes_in_area(
{x = pos.x - r, y = pos.y - r, z = pos.z - r},
{x = pos.x + r, y = pos.y + r, z = pos.z + r},
{"protector:protect", "protector:protect2"})
local meta, owner, members
- for _, pos in pairs(positions) do
+ for n = 1, #pos do
- meta = minetest.get_meta(pos)
+ meta = minetest.get_meta(pos[n])
owner = meta:get_string("owner") or ""
members = meta:get_string("members") or ""
@@ -161,7 +162,7 @@ protector.can_dig = function(r, pos, digger, onlyowner, infolevel)
"This area is owned by " .. owner .. ".")
minetest.chat_send_player(digger,
- "Protection located at: " .. minetest.pos_to_string(pos))
+ "Protection located at: " .. minetest.pos_to_string(pos[n]))
if members ~= "" then
@@ -180,7 +181,7 @@ protector.can_dig = function(r, pos, digger, onlyowner, infolevel)
"This area is owned by " .. owner .. ".")
minetest.chat_send_player(digger,
- "Protection located at: " .. minetest.pos_to_string(pos))
+ "Protection located at: " .. minetest.pos_to_string(pos[n]))
if members ~= "" then
@@ -195,7 +196,7 @@ protector.can_dig = function(r, pos, digger, onlyowner, infolevel)
if infolevel == 2 then
- if #positions < 1 then
+ if #pos < 1 then
minetest.chat_send_player(digger,
"This area is not protected.")
@@ -489,7 +490,8 @@ minetest.register_entity("protector:display", {
on_activate = function(self, staticdata)
-- Xanadu server only
- if mobs and mobs.entity and mobs.entity == false then
+ if (mobs and mobs.entity and mobs.entity == false)
+ or not self then
self.object:remove()
end
end,