-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommands.lua
69 lines (57 loc) · 1.54 KB
/
commands.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
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
minetest.register_privilege("nonew", "Allow configuring nonew")
local function tokenize(argstring)
local args = {}
for token in argstring:gmatch("[^%s]+") do
args[#args+1] = token
end
return args
end
minetest.register_chatcommand("nn_unblockall", {
description = "Unblock all players",
privs = {nonew = true},
func = function(caller, argstring)
nonew:unblock_all()
end,
})
minetest.register_chatcommand("nn_unblock", {
description = "Unblock players",
privs = {nonew = true},
params = "<player1> <player2> ...",
func = function(caller, argstring)
local tokens = tokenize(argstring)
for i = 1, #tokens do
minetest.debug("NoNew: "..caller.." unblocks "..tokens[i])
nonew:unblock( tokens[i] )
end
end,
})
minetest.register_chatcommand("nn_block", {
description = "",
privs = {nonew = true},
params = "<player1> <player2> ...",
func = function(caller, argstring)
local tokens = tokenize(argstring)
for i = 1, #tokens do
minetest.debug("NoNew: "..caller.." blocks "..tokens[i])
nonew:block( tokens[i] )
end
end,
})
local function setstate(caller, argstring, option)
local tokens = tokenize(argstring)
local value = tokens[1]
if value == 'on' then
nonew[option] = true
elseif value == 'off' then
nonew[option] = false
end
minetest.chat_send_player(caller, "NoNew "..option..": "..tostring(nonew[option]) )
end
minetest.register_chatcommand("nn_state",{
description = "",
privs = {nonew = true},
params = "{ on | off }",
func = function(caller, argstring)
setstate(caller, argstring, "state")
end,
})