summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShadowNinja <noreply@gmail.com>2013-09-03 17:09:11 -0400
committerShadowNinja <noreply@gmail.com>2013-09-03 17:09:11 -0400
commitb1a4f878ef56b23d7e49051e361819b2f7e96e14 (patch)
tree59117d591acbf5bc1da4f03031582bde167288ae
parent7b0ff512f7f44fde11204e57f5b9b30ae550e4bb (diff)
Fix rename_area and buildable_to nodes on the edges of areas
-rw-r--r--chatcommands.lua5
-rw-r--r--interact.lua39
-rw-r--r--internal.lua2
3 files changed, 25 insertions, 21 deletions
diff --git a/chatcommands.lua b/chatcommands.lua
index 8a22887..2f320ff 100644
--- a/chatcommands.lua
+++ b/chatcommands.lua
@@ -144,14 +144,14 @@ minetest.register_chatcommand("rename_area", {
privs = {},
func = function(name, param)
local found, _, id, newName = param:find("^(%d+)%s(.+)$")
-
if not found then
minetest.chat_send_player(name,
"Invalid usage, see /help rename_area")
return
end
- index = areas:getIndexById(tonumber(id))
+ id = tonumber(id)
+ index = areas:getIndexById(id)
if not index then
minetest.chat_send_player(name, "That area doesn't exist.")
@@ -165,6 +165,7 @@ minetest.register_chatcommand("rename_area", {
areas.areas[index].name = newName
areas:save()
+ minetest.chat_send_player(name, "Area renamed.")
end})
diff --git a/interact.lua b/interact.lua
index f6a7cb1..feba9e5 100644
--- a/interact.lua
+++ b/interact.lua
@@ -10,30 +10,33 @@ if minetest.can_interact then
old_can_interact = minetest.can_interact
function minetest.can_interact(pos, name)
if not areas:canInteract(pos, name) then
- printWarning(name, pos)
return false
end
return old_can_interact(pos, name)
end
-else
- local old_node_place = minetest.item_place_node
- function minetest.item_place_node(itemstack, placer, pointed_thing)
- -- XXX: buildable_to nodes can mess this up
- local pos = pointed_thing.above
- if not areas:canInteract(pos, placer:get_player_name()) then
- printWarning(placer:get_player_name(), pos)
- return itemstack -- Abort place.
- end
- return old_node_place(itemstack, placer, pointed_thing)
+end
+
+local old_node_place = minetest.item_place_node
+function minetest.item_place_node(itemstack, placer, pointed_thing)
+ local pos = pointed_thing.above
+ local ndef = minetest.registered_nodes[pointed_thing.under]
+ if ndef and ndef.buildable_to then
+ pos = pointed_thing.under
end
- local old_node_dig = minetest.node_dig
- function minetest.node_dig(pos, node, digger)
- if not areas:canInteract(pos, digger:get_player_name()) then
- printWarning(digger:get_player_name(), pos)
- return -- Abort dig.
- end
- return old_node_dig(pos, node, digger)
+ if not areas:canInteract(pos, placer:get_player_name()) then
+ printWarning(placer:get_player_name(), pos)
+ return itemstack -- Abort place.
+ end
+ return old_node_place(itemstack, placer, pointed_thing)
+end
+
+local old_node_dig = minetest.node_dig
+function minetest.node_dig(pos, node, digger)
+ if not areas:canInteract(pos, digger:get_player_name()) then
+ printWarning(digger:get_player_name(), pos)
+ return -- Abort dig.
end
+ return old_node_dig(pos, node, digger)
end
diff --git a/internal.lua b/internal.lua
index 142e610..80187dc 100644
--- a/internal.lua
+++ b/internal.lua
@@ -186,7 +186,7 @@ end
-- Checks if a player owns an area or a parent of it
function areas:isAreaOwner(id, name)
- cur = self:getAreaById(id)
+ local cur = self:getAreaById(id)
if cur and minetest.check_player_privs(name, {areas=true}) then
return true
end