logo bannerlogo banner

joining games

Warning

this is for yolkbot 2.0, which is in open beta. visit the old documentation to learn about the current release version of yolkbot.

if you don't know the code:

then, you can call join to...join it or something. when the await for join finishes, bot.game is ready but bot.me and bot.players don't have data. these are populated in the next few seconds as the game sends player data.

useful things to know about ingame:

  • bot.me is the bot's player object, which refers to how the bot is ingame (is it playing, the health, etc) - points to the index of bot.players that is the bot
  • bot.players is the array of all players in the game, including the bot. each player object has an id that is the unique identifier for that player, and a name that is the player's username the id doubles as the index in the players array
  • bot.emit is how you send events to the game. for example, to move forward you emit bot.emit('movement', Movement.Forward). if you want to chat, you can emit a chat event with the message. there are a lot of events you can emit, and they are all documented in the link.
  • bot.on is how you listen for events from the game. for example, you can listen for playerJoin to know when a new player joins, or chat to know when a message is sent in chat. there are a lot of events you can listen for, and they are all documented in the link.
  • bot.onAny is a special event listener that listens for all events. it takes the event name as the first argument, and the event data as the second argument. this is useful for debugging or if you don't know what event does what.

advanced information on chatting can be found here.