-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcommand_runners.lua
46 lines (44 loc) · 2 KB
/
command_runners.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
--local bc = better_commands
local S = minetest.get_translator(minetest.get_current_modname())
better_commands.register_command("bc", {
params = S("<command>"),
description = S("Runs any Better Commands command, so Better Commands don't have to override existing commands"),
privs = {},
func = function(name, param, context)
local command, command_param = param:match("^%/?([%S]+)%s*(.-)$")
local def = better_commands.commands[command]
if def then
local privs = context.command_block
local missing
if not privs then privs, missing = minetest.check_player_privs(name, def.privs) end
if privs then
return def.real_func(name, command_param, context)
else
return false, better_commands.error(S("You don't have permission to run this command (missing privileges: @1)", table.concat(missing, ", "))), 0
end
else
return false, better_commands.error(S("Invalid command: @1", command)), 0
end
end
})
better_commands.register_command("old", {
params = S("<command>"),
description = S("Runs any command that Better Commands has overridden"),
privs = {},
func = function(name, param, context)
local command, command_param = param:match("^%/?([%S]+)%s*(.-)$")
local def = better_commands.old_commands[command]
if def then
local privs = context.command_block
local missing
if not privs then privs, missing = minetest.check_player_privs(name, def.privs) end
if privs then
return def.real_func(name, command_param, context)
else
return false, better_commands.error(S("You don't have permission to run this command (missing privileges: @1)", table.concat(missing, ", "))), 0
end
else
return false, better_commands.error(S("Invalid command: @1", command)), 0
end
end
})