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

Method ScriptSetCallIn

src/lua/LuaHandle.cpp:580–616  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

578
579
580int LuaHandle::ScriptSetCallIn(lua_State* L) {
581 const std::string ciName = luaL_checkstring(L, 1);
582
583 const int ciCode = luaCallInDB.GetCode(ciName);
584 if (ciCode == 0) {
585 if (devMode) {
586 LuaLog(1, "Request to update an Unknown call-in (%s)\n", ciName.c_str());
587 }
588 return luaL_pushnil(L);
589 }
590
591 if (!L2H(L)->CanUseCallIn(ciName)) {
592 return luaL_pushnil(L);
593 }
594
595 lua_settop(L, 2);
596 const bool haveFunc = lua_isfunction(L, 2);
597
598 lua_checkstack(L, 4);
599
600 lua_pushvalue(L, 2); // make a copy
601 lua_rawseti(L, LUA_CALLINSINDEX, ciCode);
602
603 lua_pushstring(L, ciName.c_str());
604 lua_pushvalue(L, 2); // make a copy
605 lua_rawset(L, LUA_CALLINSINDEX);
606
607 const std::string& eventName = luaCallInDB.GetEventName(ciName);
608 if (eventHandler.IsManaged(eventName)) {
609 lua_pushboolean(L, L2H(L)->UpdateCallIn(ciName, haveFunc));
610 }
611 else {
612 lua_pushboolean(L, true);
613 }
614
615 return 1;
616}
617
618
619//============================================================================//

Callers

nothing calls this directly

Calls 15

LuaLogFunction · 0.85
luaL_pushnilFunction · 0.85
L2HFunction · 0.85
c_strMethod · 0.80
CanUseCallInMethod · 0.80
UpdateCallInMethod · 0.80
lua_settopFunction · 0.50
lua_checkstackFunction · 0.50
lua_pushvalueFunction · 0.50
lua_rawsetiFunction · 0.50
lua_pushstringFunction · 0.50
lua_rawsetFunction · 0.50

Tested by

no test coverage detected