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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
-- This small mod transitions the protector_redo mod to the areas.
local r = 7
minetest.register_abm({
nodenames = {"protector:protect","protector:protect_sell"},
interval = 8,
chance = 1,
catch_up = false,
action = function(pos, node)
local meta = minetest.get_meta(pos)
local name = meta:get_string("owner")
local pos1 = {x = pos.x - r, y = pos.y - r, z = pos.z - r}
local pos2 = {x = pos.x + r, y = pos.y + r, z = pos.z + r}
if not (pos1 and pos2) then
return false, "You need to select an area first."
end
minetest.log("action", "/protect invoked, owner="..name..
" AreaName=".."Converted from protectors"..
" StartPos="..minetest.pos_to_string(pos1)..
" EndPos=" ..minetest.pos_to_string(pos2))
local id = areas:add(name, "Converted from Protectors", pos1, pos2, nil)
areas:save()
minetest.chat_send_all("Area protected. ID: "..id)
minetest.set_node(pos, {name = "markers:stone"})
return true
end
})
minetest.register_abm({
nodenames = {"protector:protect2"},
interval = 8,
chance = 1,
catch_up = false,
action = function(pos, node)
local meta = minetest.get_meta(pos)
local name = meta:get_string("owner")
local pos1 = {x = pos.x - r, y = pos.y - r, z = pos.z - r}
local pos2 = {x = pos.x + r, y = pos.y + r, z = pos.z + r}
if not (pos1 and pos2) then
return false, "You need to select an area first."
end
minetest.log("action", "/protect invoked, owner="..name..
" AreaName=".."Converted from protectors"..
" StartPos="..minetest.pos_to_string(pos1)..
" EndPos=" ..minetest.pos_to_string(pos2))
local id = areas:add(name, "Converted from Protectors", pos1, pos2, nil)
areas:save()
minetest.chat_send_all("Area protected. ID: "..id)
minetest.set_node(pos, {name = "air"})
return true
end
})
minetest.register_abm({
nodenames = {"protector:chest"},
interval = 8,
chance = 1,
catch_up = false,
action = function(pos, node)
minetest.set_node(pos, {name = "default:chest_locked"})
return true
end
})
minetest.register_abm({
nodenames = {"protector:door_wood", "protector:door_steel"},
interval = 8,
chance = 1,
catch_up = false,
action = function(pos, node)
minetest.set_node(pos, {name = "default:door_steel"})
return true
end
})
|