get_bot_index - ryzom/ryzomcore GitHub Wiki


title: Get Bot Index description: published: true date: 2023-03-12T19:42:46.709Z tags: editor: markdown dateCreated: 2023-03-12T19:42:43.359Z

getBotIndex

The getBotIndex AI script function is used to get the bot index in the group by its entityId.

Syntax

(botIndex: f)getBotIndex(botEid: s) // getBotIndex_s_f

Arguments

  • botEid (string): The entityId given by the bot.

Return values

  • botIndex (float): The position of the bot in the group or -1 if the entityId is not from a bot of the group.

Examples

($botEid)getCurrentSpeakerEid();
(index)getBotIndex($botEid);
if (index != -1)
{
    ()phrasePushValue("entity", $botEid);
    ()phraseEndNpcMsg(index, "PHRASE_YOUR_ARE_CLICKING_ON_ME");
}

This example code gets the current speaker's entityId and then gets its index in the group using the getBotIndex function. If the index is not -1 (meaning the entityId is from a bot of the group), it pushes the entityId on the parameter stack and ends an npc message with the phraseEndNpcMsg function.

⚠️ **GitHub.com Fallback** ⚠️