Skip to content

Commit 5058479

Browse files
authored
feat(PlayerMethods): Add IsBot() method (#360)
1 parent fe47a5d commit 5058479

2 files changed

Lines changed: 17 additions & 0 deletions

File tree

src/LuaEngine/LuaFunctions.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -708,6 +708,7 @@ ALERegister<Player> PlayerMethods[] =
708708
{ "CanTeleport", &LuaPlayer::CanTeleport },
709709
{ "IsSpectator", &LuaPlayer::IsSpectator },
710710
{ "HasKnownTaxiNode", &LuaPlayer::HasKnownTaxiNode },
711+
{ "IsBot", &LuaPlayer::IsBot },
711712
// { "HasSpellMod", &LuaPlayer::HasSpellMod },
712713

713714
// Gossip

src/LuaEngine/methods/PlayerMethods.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5009,6 +5009,22 @@ namespace LuaPlayer
50095009
ALE::Push(L, player->m_taxi.IsTaximaskNodeKnown(nodeId));
50105010
return 1;
50115011
}
5012+
5013+
/**
5014+
* Returns `true` if the [Player] is a Playerbot/RNDBot, `false` otherwise.
5015+
*
5016+
* @return bool isBot
5017+
*/
5018+
int IsBot(lua_State* L, Player* player)
5019+
{
5020+
#if defined(MOD_PLAYERBOTS)
5021+
ALE::Push(L, player->GetSession()->IsBot());
5022+
#else
5023+
(void)player;
5024+
ALE::Push(L, false);
5025+
#endif
5026+
return 1;
5027+
}
50125028
};
50135029
#endif
50145030

0 commit comments

Comments
 (0)