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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
|
minetest.register_chatcommand("mesecons_enable", {
description = "enables the mesecons globlastep",
privs = { mesecons_debug = true },
func = function()
-- flush actions, while we are on it
mesecon.queue.actions = {}
mesecons_debug.mesecons_enabled = true
return true, "mesecons enabled"
end
})
minetest.register_chatcommand("mesecons_disable", {
description = "disables the mesecons globlastep",
privs = { mesecons_debug = true },
func = function()
mesecons_debug.mesecons_enabled = false
return true, "mesecons disabled"
end
})
minetest.register_chatcommand("mesecons_whitelist_get", {
description = "shows the current mapblock whitelist",
privs = { mesecons_debug = true },
func = function()
local count = 0
local list = {}
for hash, _ in pairs(mesecons_debug.storage:to_table().fields) do
table.insert(list, minetest.pos_to_string(minetest.get_position_from_hash(hash)))
count = count + 1
end
return true, (
"mesecons whitelist:\n" ..
"%s\n" ..
"%i mapblocks whitelisted"
):format(
table.concat(list, "\n"),
count
)
end
})
minetest.register_chatcommand("mesecons_whitelist_add", {
description = "adds the current mapblock to the whitelist",
privs = { mesecons_debug = true },
func = function(name)
local player = minetest.get_player_by_name(name)
if not player then
return
end
local hash = mesecons_debug.hashpos(player:get_pos())
local ctx = mesecons_debug.get_context(hash)
ctx.whitelisted = true
mesecons_debug.storage:set_string(hash, "1")
return true, "mapblock whitlisted"
end
})
minetest.register_chatcommand("mesecons_whitelist_remove", {
description = "removes the current mapblock from the whitelist",
privs = { mesecons_debug = true },
func = function(name)
local player = minetest.get_player_by_name(name)
if not player then
return
end
local hash = mesecons_debug.hashpos(player:get_pos())
local ctx = mesecons_debug.get_context(hash)
ctx.whitelisted = false
mesecons_debug.storage:set_string(hash, "")
return true, "mapblock removed from whitelist"
end
})
minetest.register_chatcommand("mesecons_debug_set", {
description = "modify mesecons_debug settings",
params = "<setting> <value>",
privs = { mesecons_debug = true },
func = function(name, params)
local player = minetest.get_player_by_name(name)
if not player or not params then
return false
end
local setting, value = params:match('^([a-zA-Z0-9_-]+)%s+(.*)$')
value = tonumber(value)
if not setting or not value then
return false
end
if not mesecons_debug.settings[setting] then
return false, "unknown setting"
end
mesecons_debug.settings.modify_setting(setting, value)
return true, "setting updated"
end
})
minetest.register_chatcommand("mesecons_debug_get", {
description = "get mesecons_debug settings",
params = "<setting>",
privs = { mesecons_debug = true },
func = function(name, setting)
local player = minetest.get_player_by_name(name)
if not player or not setting then
return false
end
local value = mesecons_debug.settings[setting]
if value then
return true, tostring(value)
else
return false, "unknown setting"
end
end
})
|