Display Chat Message on Player Interaction

Hello!

I was wondering if there was a way to display a message in the chat for everyone when a player interacts with an object or steps on a specific tile. It would essentially be the combination of playerInteracts or playerMoves with playerChats.

When using game.chat(“GLOBAL_CHAT”, [], mapId, “chat message”), it doesn’t seem to display anything in the chat side panel, and I haven’t seen anything in the data or context for either subscriptions which worked for me. Any and all insights on this are greatly appreciated! Even if it doesn’t exist yet, that would still help me from spinning my wheels lol.

Thanks!
Kevin

You’re up against the thing I hate the most about using the Chat via API. If your account is the API key holder, you will not see chat messages sent “by you”, ie via the API.

Log in with another account, or an incognito window, and you will see that the API account is in fact chatting, but doesn’t get to see it.

Another way to check is to subscribe to playerChats. You’ll see your UUID chatting that way too.

There is also a whole slew of issues with chat ranges and any chat other than Global, but ill leave those for another time.

1 Like

Super helpful info @Bill_Uncork-It! Didn’t realize that it wasn’t posting for me because it’s my API key. Very good to know. I thought I was going crazy and something was wrong with my code haha.

Have you had any luck posting messages in the global chat triggered by interactions or movement?

Yeah, I’ve been able to send messages as a result of interactions. I’ve found direct messages (DMs) to be better than Nearby or Room chat, as the chat seems to use the API key holder’s position for these chat functions. This means the only usable channels are global (so everyone hears it) or to single players (which I’ve found a little spammy).

Oh wow, you’re right! My code has been working the entire time, but I just thought it was broken because nothing ever came up in the chat. Using your incognito trick to test as an anonymous user got both my interactions and movements working in the chat perfectly! Thanks again Bill!

Most of my team’s time has been diving into playerInteracts and playerMoves, but we’re just starting to get into playerChats now. I know you’ve done a ton of great work with bots and chat. I feel like we should be documenting all of the possibilities and limitations of each subscription somewhere.

At least now I can confirm that it is really easy to display chat messages on interactions or player moves. :grinning_face_with_smiling_eyes: :+1: