| 339 | |
| 340 | |
| 341 | bool LuaClientScripts::LuaWorldCommand(const std::string& cmdLine) { |
| 342 | const World* world = World::getWorld(); |
| 343 | if (world == NULL) { |
| 344 | return false; |
| 345 | } |
| 346 | |
| 347 | const std::string prefix = "luaworld"; |
| 348 | const char* c = cmdLine.c_str(); |
| 349 | if (strncmp(c, prefix.c_str(), prefix.size()) != 0) { |
| 350 | return false; |
| 351 | } |
| 352 | c = TextUtils::skipWhitespace(c + prefix.size()); |
| 353 | |
| 354 | const std::string cmd = c; |
| 355 | if (cmd == "reload") { |
| 356 | LuaWorld::FreeHandler(); |
| 357 | LuaWorld::LoadHandler(); |
| 358 | } |
| 359 | else if (cmd == "disable") { |
| 360 | const bool active = (luaWorld != NULL); |
| 361 | LuaWorld::FreeHandler(); |
| 362 | if (active) { |
| 363 | showMessage("LuaWorld disabled"); |
| 364 | } |
| 365 | } |
| 366 | else if (cmd == "status") { |
| 367 | if (luaWorld != NULL) { |
| 368 | showMessage("LuaWorld is enabled"); |
| 369 | } |
| 370 | else { |
| 371 | showMessage("LuaWorld is disabled"); |
| 372 | } |
| 373 | } |
| 374 | else if (cmd == "") { |
| 375 | addMessage(NULL, |
| 376 | "/luaworld < status | reload | disable | custom_command ... >"); |
| 377 | } |
| 378 | else if (luaWorld != NULL) { |
| 379 | return luaWorld->RecvCommand(c); |
| 380 | } |
| 381 | else { |
| 382 | return false; |
| 383 | } |
| 384 | |
| 385 | return true; |
| 386 | } |
| 387 | |
| 388 | |
| 389 | bool LuaClientScripts::LuaRulesCommand(const std::string& cmdLine) { |
nothing calls this directly
no test coverage detected