| 387 | |
| 388 | |
| 389 | bool 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 | } |
nothing calls this directly
no test coverage detected