Only “whitelist chats” (a.k.a. “safe chats”) may be created, where users can choose from a preselected list of messages. Free chats or blacklist chats, where users can post any message or where certain specific words/phrases are not allowed but otherwise messages are unrestricted, respectively, are not allowed, as there is a significant potential for bullying (more so than other places since users think only a few people will see their messages) or personal information being revealed and it would be very difficult for the Scratch Team to moderate them.
|Note:||The Scratch Team does not encourage the creation of chat rooms. If someone needs to be told something, use the comments, which are usually much safer, and monitored more closely by the Scratch team.|
This tutorial makes a “safe chat” with the messages:
- How was your day?
This tutorial will assume several variables. These are:
One list called “Chat” will be used too. This list will show the chat log.
Sending a Message
To send a message to the chat room, first add the message to the list “Chat”.
Next, encode the entire chat log to ☁data. This process runs through every character in every list item and encodes the character as a two-digit number, then add “00” to separate list items since there is no 0th character of a piece of text. Both define blocks need to have “run without screen refresh” checked when making them.
whenclickedsetctoabcdefghijklmnopqrstuvwxyz0123456789_-.?!:�These are all supported username characters + characters in our messages + colon for separation of user and message + one "unknown character" character for contingencies.defineencodesetito0set☁datatorepeatlengthofChatchangeiby1setjto0repeatlengthofitemiofChatchangejby1setkto0repeatuntilletterjofitemiofChat=letterkofcork>lengthofcchangekby1ifk>lengthofcthensetktolengthofc...replace that letter with the "unknown character" characterif such a character is out of range of c...ifk<10thenset☁datatojoin☁datajoin0k...make it two digits by adding a 0 in front, e.g. 4 becomes 04elseset☁datatojoin☁datakif the resulting number is less than two digits long...set☁datatojoin☁data00
Receiving a message
To see messages on the list that have been sent, decode ☁data into our list. This will take every two characters of ☁data and turn them back into a text character.
To make an interface to send and receive messages, simply always ask for a message, then send it. Preferably, this would be in the Stage.