And I also want to know about the input “localPlayers” of game.chat(), it is a string array.
I’m not sure what is this meaning, I think this input is mening who send the message,
because localPlayers is empty array and playerChats wasn’t triggered, is this correct?
There are so many question can anyone help me?
Thanks!
By the way
I didn’t try yet, if I want to Whisper to other player
I need to using enterWhisper and chat both, is this correct?
Try logging in a second avatar. I usually just open an incognito tab.
For some reason, the game.chat function will send a chat to global_chat, but not put any log of it into your own chat box. Meaning if you are trying to test some sort of chat-back interaction, and happen to be logged in on the avatar the API key is tied to, you will never see the chats.
Local players still confuses me, as it seems like it might be redundant with Nearby. I’ve really only focused on Global_chat while I’ve tried to get my coding going, as it has the least oddities.
Remember that Whisper is not a chat function, despite the name. Whisper is an ad hoc private space between two people, for voice and video.
Just offering a bit of context for what the options are for the recipient field are, and how localPlayerIds works;
If chatRecipient is set to GLOBAL_CHAT, the message will be sent to all users, and localPlayerIds is ignored.
If chatRecipient is set to LOCAL_CHAT, the message will be sent to each user specified in localPlayerIds.
If chatRecipient is set to ROOM_CHAT, the message will be sent to each user inside a room (‘current room’). localPlayerIds is also ignored here.
Thank you @opalrose
But I have new question now.
If chatRecipient and localPlayers both meaning who will get message, then how can I set message sender by using API?
I’m trying to let player send message to bot by using private message, and bot can auto send message back to player.
The message sender will always be the account tied to the API. There are some oddities for this, especially if the api account hasn’t ever logged into the space, but there is no way to alter what account sends the chats.