Check if the player who placed constructor can access protected positions before placing or removing nodes.

This commit is contained in:
auouymous 2020-09-03 01:05:53 -06:00
parent 11f2b4f4b3
commit aea4bb25b4
1 changed files with 6 additions and 0 deletions

View File

@ -88,6 +88,7 @@ minetest.register_craft({
local function make_on(mark, length)
return function(pos, node)
local meta = minetest.get_meta(pos)
local owner = meta:get_string("owner")
local inv = meta:get_inventory()
local dir = vector.new()
if node.param2 == 3 then dir.x = 1 end
@ -102,6 +103,7 @@ local function make_on(mark, length)
minetest.check_for_falling(pos)
for i = 1, length do
place_pos = vector.add(place_pos, dir)
if owner ~= "" and minetest.is_protected(place_pos, owner) then return end
local place_node = minetest.get_node(place_pos)
deploy_node(inv, "slot"..i, place_pos, place_node, node)
end
@ -157,6 +159,10 @@ local function make_constructor(mark, length)
inv:set_size("slot"..i, 1)
end
end,
after_place_node = function(pos, placer)
local meta = minetest.get_meta(pos)
meta:set_string("owner", placer:get_player_name() or "")
end,
can_dig = function(pos, player)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()