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

Method LuaWorldCommand

src/lua/LuaClientScripts.cpp:341–386  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

339
340
341bool 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
389bool LuaClientScripts::LuaRulesCommand(const std::string& cmdLine) {

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