MCPcopy Create free account
hub / github.com/BZFlag-Dev/bzflag / LuaUserCommand

Method LuaUserCommand

src/lua/LuaClientScripts.cpp:240–286  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

238//============================================================================//
239
240bool LuaClientScripts::LuaUserCommand(const std::string& cmdLine) {
241 const std::string prefix = "luauser";
242 const char* c = cmdLine.c_str();
243 if (strncmp(c, prefix.c_str(), prefix.size()) != 0) {
244 return false;
245 }
246 c = TextUtils::skipWhitespace(c + prefix.size());
247
248 const std::string cmd = c;
249 if (cmd == "reload") {
250 LuaUser::FreeHandler();
251 if (BZDB.isTrue("_forbidLuaUser")) {
252 showMessage("This server forbids LuaUser scripts");
253 return false;
254 }
255 else {
256 LuaUser::LoadHandler();
257 }
258 }
259 else if (cmd == "disable") {
260 const bool active = (luaUser != NULL);
261 LuaUser::FreeHandler();
262 if (active) {
263 showMessage("LuaUser disabled");
264 }
265 }
266 else if (cmd == "status") {
267 if (luaUser != NULL) {
268 showMessage("LuaUser is enabled");
269 }
270 else {
271 showMessage("LuaUser is disabled");
272 }
273 }
274 else if (cmd == "") {
275 addMessage(NULL,
276 "/luauser < status | reload | disable | custom_command ... >");
277 }
278 else if (luaUser != NULL) {
279 return luaUser->RecvCommand(c);
280 }
281 else {
282 return false;
283 }
284
285 return true;
286}
287
288
289bool LuaClientScripts::LuaBzOrgCommand(const std::string& cmdLine) {

Callers

nothing calls this directly

Calls 7

skipWhitespaceFunction · 0.85
addMessageFunction · 0.85
c_strMethod · 0.80
isTrueMethod · 0.80
showMessageFunction · 0.50
sizeMethod · 0.45
RecvCommandMethod · 0.45

Tested by

no test coverage detected