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

Method LuaRulesCommand

src/lua/LuaClientScripts.cpp:389–446  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

387
388
389bool LuaClientScripts::LuaRulesCommand(const std::string& cmdLine) {
390 const World* world = World::getWorld();
391 if (world == NULL) {
392 return false;
393 }
394
395 const std::string prefix = "luarules";
396 const char* c = cmdLine.c_str();
397 if (strncmp(c, prefix.c_str(), prefix.size()) != 0) {
398 return false;
399 }
400 c = TextUtils::skipWhitespace(c + prefix.size());
401
402 const std::string cmd = c;
403 if (cmd == "reload") {
404 if (!GetDevMode()) {
405 showMessage("LuaRules is a required script");
406 return false;
407 }
408 LuaRules::FreeHandler();
409 LuaRules::LoadHandler();
410 }
411 else if (cmd == "disable") {
412 if (!GetDevMode()) {
413 showMessage("LuaRules is a required script");
414 return false;
415 }
416 const bool active = (luaRules != NULL);
417 LuaRules::FreeHandler();
418 if (active) {
419 showMessage("LuaRules disabled");
420 }
421 }
422 else if (cmd == "status") {
423 if (luaRules != NULL) {
424 showMessage("LuaRules is enabled");
425 }
426 else {
427 showMessage("LuaRules is disabled");
428 }
429 }
430 else if (cmd == "") {
431 addMessage(NULL,
432 "/luarules < status | reload | disable | custom_command ... >");
433 }
434 else if (luaRules != NULL) {
435 if (!GetDevMode()) {
436 showMessage("LuaRules can not receive commands");
437 return false;
438 }
439 return luaRules->RecvCommand(c);
440 }
441 else {
442 return false;
443 }
444
445 return true;
446}

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected