summaryrefslogtreecommitdiff
path: root/admin.lua
blob: 219aff5cd663d153821afc2f90db499f60123ddf (plain)
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

local S = protector.intllib

protector.removal_names = ""

minetest.register_chatcommand("delprot", {
	params = "",
	description = S("Remove Protectors near players with names provided (separate names with spaces)"),
	privs = {server = true},
	func = function(name, param)

		if not param or param == "" then

			minetest.chat_send_player(name,
				S("Protector Names to remove: %1",
				protector.removal_names))

			return
		end

		if param == "-" then
			minetest.chat_send_player(name,
				S("Name List Reset"))

			protector.removal_names = ""

			return
		end

		protector.removal_names = param

	end,
})

minetest.register_abm({
	nodenames = {"protector:protect", "protector:protect2"},
	interval = 8,
	chance = 1,
	catch_up = false,
	action = function(pos, node)

		if protector.removal_names == "" then
			return
		end

		local meta = minetest.get_meta(pos)
		local owner = meta:get_string("owner")
		--local members = meta:get_string("members")

		local names = protector.removal_names:split(" ")

		for _, n in pairs(names) do

			if n == owner then
				minetest.set_node(pos, {name = "air"})
			end

		end

	end
})