4
4
-- Chat command handler
5
5
--
6
6
7
- core .chatcommands = {}
7
+ core .registered_chatcommands = {}
8
+ core .chatcommands = core .registered_chatcommands -- BACKWARDS COMPATIBILITY
8
9
function core .register_chatcommand (cmd , def )
9
10
def = def or {}
10
11
def .params = def .params or " "
11
12
def .description = def .description or " "
12
13
def .privs = def .privs or {}
13
14
def .mod_origin = core .get_current_modname () or " ??"
14
- core .chatcommands [cmd ] = def
15
+ core .registered_chatcommands [cmd ] = def
15
16
end
16
17
17
18
core .register_on_chat_message (function (name , message )
18
19
local cmd , param = string.match (message , " ^/([^ ]+) *(.*)" )
19
20
if not param then
20
21
param = " "
21
22
end
22
- local cmd_def = core .chatcommands [cmd ]
23
+ local cmd_def = core .registered_chatcommands [cmd ]
23
24
if not cmd_def then
24
25
return false
25
26
end
@@ -107,7 +108,7 @@ core.register_chatcommand("help", {
107
108
if param == " " then
108
109
local msg = " "
109
110
local cmds = {}
110
- for cmd , def in pairs (core .chatcommands ) do
111
+ for cmd , def in pairs (core .registered_chatcommands ) do
111
112
if core .check_player_privs (name , def .privs ) then
112
113
cmds [# cmds + 1 ] = cmd
113
114
end
@@ -118,7 +119,7 @@ core.register_chatcommand("help", {
118
119
.. " or '/help all' to list everything."
119
120
elseif param == " all" then
120
121
local cmds = {}
121
- for cmd , def in pairs (core .chatcommands ) do
122
+ for cmd , def in pairs (core .registered_chatcommands ) do
122
123
if core .check_player_privs (name , def .privs ) then
123
124
cmds [# cmds + 1 ] = format_help_line (cmd , def )
124
125
end
@@ -134,7 +135,7 @@ core.register_chatcommand("help", {
134
135
return true , " Available privileges:\n " .. table.concat (privs , " \n " )
135
136
else
136
137
local cmd = param
137
- local def = core .chatcommands [cmd ]
138
+ local def = core .registered_chatcommands [cmd ]
138
139
if not def then
139
140
return false , " Command not available: " .. cmd
140
141
else
@@ -161,7 +162,7 @@ local function handle_grant_command(caller, grantname, grantprivstr)
161
162
if not (caller_privs .privs or caller_privs .basic_privs ) then
162
163
return false , " Your privileges are insufficient."
163
164
end
164
-
165
+
165
166
if not core .get_auth_handler ().get_auth (grantname ) then
166
167
return false , " Player " .. grantname .. " does not exist."
167
168
end
@@ -204,7 +205,7 @@ core.register_chatcommand("grant", {
204
205
local grantname , grantprivstr = string.match (param , " ([^ ]+) (.+)" )
205
206
if not grantname or not grantprivstr then
206
207
return false , " Invalid parameters (see /help grant)"
207
- end
208
+ end
208
209
return handle_grant_command (name , grantname , grantprivstr )
209
210
end ,
210
211
})
@@ -215,7 +216,7 @@ core.register_chatcommand("grantme", {
215
216
func = function (name , param )
216
217
if param == " " then
217
218
return false , " Invalid parameters (see /help grantme)"
218
- end
219
+ end
219
220
return handle_grant_command (name , name , param )
220
221
end ,
221
222
})
0 commit comments