/** * @luafunc void LuaLevelGenerator::setGameTime(num timeInMinutes) * * @brief Sets the time remaining in the current game to the specified value * * @param timeInMinutes Time, in minutes, that the game should continue. Can be * fractional. */ S32 LuaLevelGenerator::lua_setGameTime(lua_State *L) { checkArgList(L, functionArgs, luaClassName, "setGameTime"); mGame->setGameTime(getFloat(L, 1)); return 0; }
/** * @luafunc void LineItem::setGlobal(bool global) * * @brief Sets the LineItem's global parameter. * * @descr LineItems are normally viewable by all players in a game. If you wish * to only let the LineItem be viewable to the owning team, set to `false`. Make * sure you call setTeam() on the LineItem first. Global is on by default. * * @param global `false` if this LineItem should be viewable only by the owning * team, otherwise viewable by all teams. */ S32 LineItem::lua_setGlobal(lua_State *L) { checkArgList(L, functionArgs, "LineItem", "setGlobal"); mGlobal = getBool(L, 1); setMaskBits(0x80000000); // Update to clients, dummy mask because of no mask bits used on packUpdate return 0; }
/** * @luafunc LuaLevelGenerator::announce(string message) * * @brief Broadcast an announcement. * * @param message Message to broadcast. */ S32 LuaLevelGenerator::lua_announce(lua_State *L) { checkArgList(L, functionArgs, luaClassName, "announce"); string message = getString(L, 1); mGame->sendAnnouncementFromController(message); return 0; }
/** * @luafunc Team LuaGameInfo::getTeam(int teamIndex) * * @brief Get a Team by index. * * @note Remember that Lua uses 1-based indices, so the index of the first team will be 1. * * @return The Team with the specified index. */ S32 LuaGameInfo::lua_getTeam(lua_State *L) { checkArgList(L, functionArgs, "GameInfo", "getTeam"); S32 index = getTeamIndex(L, 1); if(U32(index) >= U32(mServerGame->getTeamCount())) // Out of range index? return returnNil(L); TNLAssert(dynamic_cast<Team*>(mServerGame->getTeam(index)), "Bad team pointer or bad type"); return returnTeam(L, static_cast<Team*>(mServerGame->getTeam(index))); }
// Note that identical code is found in Robot::lua_privateMsg() S32 LuaLevelGenerator::lua_privateMsg(lua_State *L) { checkArgList(L, functionArgs, luaClassName, "privateMsg"); const char *message = getString(L, 1); const char *playerName = getString(L, 2); mGame->sendPrivateChat(levelControllerName, playerName, message); // No event fired for private message return 0; }
/** * @luafunc NexusZone::setClosedTime(int seconds) * * @brief Set the time (in seconds) that the Nexus will remain closed. * * @descr Pass 0 if the Nexus should never open, causing the Nexus to remain * closed permanently. Passing a negative time will generate an error. * * @param seconds Time in seconds that the Nexus should remain closed. * * @note Since all Nexus items open and close together, this method will affect * all Nexus items in a game. * * Also note that in a level file, closing times are specified in fractions of * minutes, whereas this method works with seconds. */ S32 NexusZone::lua_setClosedTime(lua_State *L) { checkArgList(L, functionArgs, "NexusZone", "setCloseTime"); if(!mGame) return 0; GameType *gameType = mGame->getGameType(); if(gameType->getGameTypeId() != NexusGame) // Do nothing if this is not a Nexus game return 0; static_cast<NexusGameType *>(gameType)->setNewClosedTime(getInt(L, 1)); return 0; }
/** * @luafunc void LuaLevelGenerator::globalMsg(string message) * * @brief Broadcast a message to all players. * * @param message Message to broadcast. */ S32 LuaLevelGenerator::lua_globalMsg(lua_State *L) { checkArgList(L, functionArgs, luaClassName, "globalMsg"); const char *message = getString(L, 1); mGame->sendChat(levelControllerName, NULL, message, true, NO_TEAM); // Clean up before firing event lua_pop(L, 1); // Fire our event handler EventManager::get()->fireEvent(this, EventManager::MsgReceivedEvent, message, NULL, true); return 0; }
// Combined Lua / C++ constructor) NexusZone::NexusZone(lua_State *L) { mObjectTypeNumber = NexusTypeNumber; mNetFlags.set(Ghostable); if(L) { static LuaFunctionArgList constructorArgList = { {{ END }, { POLY, END }}, 2 }; S32 profile = checkArgList(L, constructorArgList, "NexusZone", "constructor"); if(profile == 1) setGeom(L, 1); LUA_REGISTER_WITH_TRACKER; } LUAW_CONSTRUCTOR_INITIALIZATIONS; }