mirror of
https://github.com/minetest-mods/areas.git
synced 2024-12-25 18:20:39 +01:00
Fix rename_area and buildable_to nodes on the edges of areas
This commit is contained in:
parent
7b0ff512f7
commit
b1a4f878ef
@ -144,14 +144,14 @@ minetest.register_chatcommand("rename_area", {
|
|||||||
privs = {},
|
privs = {},
|
||||||
func = function(name, param)
|
func = function(name, param)
|
||||||
local found, _, id, newName = param:find("^(%d+)%s(.+)$")
|
local found, _, id, newName = param:find("^(%d+)%s(.+)$")
|
||||||
|
|
||||||
if not found then
|
if not found then
|
||||||
minetest.chat_send_player(name,
|
minetest.chat_send_player(name,
|
||||||
"Invalid usage, see /help rename_area")
|
"Invalid usage, see /help rename_area")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
index = areas:getIndexById(tonumber(id))
|
id = tonumber(id)
|
||||||
|
index = areas:getIndexById(id)
|
||||||
|
|
||||||
if not index then
|
if not index then
|
||||||
minetest.chat_send_player(name, "That area doesn't exist.")
|
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.areas[index].name = newName
|
||||||
areas:save()
|
areas:save()
|
||||||
|
minetest.chat_send_player(name, "Area renamed.")
|
||||||
end})
|
end})
|
||||||
|
|
||||||
|
|
||||||
|
21
interact.lua
21
interact.lua
@ -10,30 +10,33 @@ if minetest.can_interact then
|
|||||||
old_can_interact = minetest.can_interact
|
old_can_interact = minetest.can_interact
|
||||||
function minetest.can_interact(pos, name)
|
function minetest.can_interact(pos, name)
|
||||||
if not areas:canInteract(pos, name) then
|
if not areas:canInteract(pos, name) then
|
||||||
printWarning(name, pos)
|
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
return old_can_interact(pos, name)
|
return old_can_interact(pos, name)
|
||||||
end
|
end
|
||||||
else
|
end
|
||||||
local old_node_place = minetest.item_place_node
|
|
||||||
function minetest.item_place_node(itemstack, placer, pointed_thing)
|
local old_node_place = minetest.item_place_node
|
||||||
-- XXX: buildable_to nodes can mess this up
|
function minetest.item_place_node(itemstack, placer, pointed_thing)
|
||||||
local pos = pointed_thing.above
|
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
|
||||||
|
|
||||||
if not areas:canInteract(pos, placer:get_player_name()) then
|
if not areas:canInteract(pos, placer:get_player_name()) then
|
||||||
printWarning(placer:get_player_name(), pos)
|
printWarning(placer:get_player_name(), pos)
|
||||||
return itemstack -- Abort place.
|
return itemstack -- Abort place.
|
||||||
end
|
end
|
||||||
return old_node_place(itemstack, placer, pointed_thing)
|
return old_node_place(itemstack, placer, pointed_thing)
|
||||||
end
|
end
|
||||||
|
|
||||||
local old_node_dig = minetest.node_dig
|
local old_node_dig = minetest.node_dig
|
||||||
function minetest.node_dig(pos, node, digger)
|
function minetest.node_dig(pos, node, digger)
|
||||||
if not areas:canInteract(pos, digger:get_player_name()) then
|
if not areas:canInteract(pos, digger:get_player_name()) then
|
||||||
printWarning(digger:get_player_name(), pos)
|
printWarning(digger:get_player_name(), pos)
|
||||||
return -- Abort dig.
|
return -- Abort dig.
|
||||||
end
|
end
|
||||||
return old_node_dig(pos, node, digger)
|
return old_node_dig(pos, node, digger)
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -186,7 +186,7 @@ end
|
|||||||
|
|
||||||
-- Checks if a player owns an area or a parent of it
|
-- Checks if a player owns an area or a parent of it
|
||||||
function areas:isAreaOwner(id, name)
|
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
|
if cur and minetest.check_player_privs(name, {areas=true}) then
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user