forked from Bremaweb/landrush
-
Notifications
You must be signed in to change notification settings - Fork 3
/
doors.lua
30 lines (26 loc) · 1.06 KB
/
doors.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
function landrush.protect_against_door(door)
local definition = minetest.registered_items[door]
local on_place = definition.on_place
function definition.on_place(itemstack, placer, pointed_thing)
local bottom = pointed_thing.above
local top = {x=pointed_thing.above.x, y=pointed_thing.above.y+1, z=pointed_thing.above.z}
local name = placer:get_player_name()
if landrush.can_interact(top,name) and landrush.can_interact(bottom, name) then
return on_place(itemstack, placer, pointed_thing)
else
local topowner = landrush.get_owner(top)
local bottomowner = landrush.get_owner(bottom)
if topowner and bottomowner and topowner ~= bottomowner then
minetest.chat_send_player(name, "Area owned by "..topowner.." and "..bottomowner)
elseif topowner then
minetest.chat_send_player(name, "Area owned by "..topowner)
else
minetest.chat_send_player(name, "Area owned by "..bottomowner)
end
end
end
end
if minetest.get_modpath("doors") then
landrush.protect_against_door("doors:door_wood")
landrush.protect_against_door("doors:door_steel")
end