Discuss Scratch

atorubarov
Scratcher
10 posts

Chat Rooms

I need help making a chat room.
By ciphering words to numbers then deciphering.
Keeping all the information in a cloud variable is what I can do, but I need help with the ciphering and deciphering.
Babissimo
Scratcher
100+ posts

Chat Rooms

What do you mean, what part of it
DudmasterUltra
Scratcher
100+ posts

Chat Rooms

This is really complex, but if you understand that type of stuff, read on.

I have made a pretty advanced Scratch chat client which I keep unshared since they are not allowed. It has features like banning, kicking, and broadcasting announcements. You can change your username and it's all encoded into numbers.
The way it works is pretty simple, you take a string of numbers, let's say “hello”.
Encoded it looks like this: 0805121215
The easiest way to learn how to encode is having a loop that repeats for the length of the text you're trying to encode.
Inside the loop, there should be if statements asking if the letter that is selected during the encode process is a, b, c, so on…
like this:
set (encoded text) to []
repeat (length of (text))

if <(letter (int) of (text)) = [a]> then

set (encoded text) to (join (encoded text) [01])
end
change (int) by (1)
end
This script will detect when the letter “a” shows up in your encoded text and add that to the encoded string.
Of course you will need a script like this to detect every letter of the alphabet, numbers, and symbols.
To make a chat room that has a list of comments instead of one vairable, make a list that adds the decoded text variable to it every
time it changes.
WarriorLakepelt
Scratcher
100+ posts

Chat Rooms

Free chat rooms arent allowed, but safe chat rooms are, but try DudmasterUltra's idea.
derpmeup
Scratcher
1000+ posts

Chat Rooms

atorubarov wrote:

I need help making a chat room.
By ciphering words to numbers then deciphering.
Keeping all the information in a cloud variable is what I can do, but I need help with the ciphering and deciphering.

Well, chat rooms are not allowed on Scratch. But, you can make a safe chat room which gives you options on what you can say.
sunman
New Scratcher
1 post

Chat Rooms

Chats are a good idea, but better left a private thing. If it is for friends find a way to password protect it and you will have a nice setup. Of course, you have the whole no chat rooms thing, but studios make a good replacement
Alberknyis
Scratcher
1000+ posts

Chat Rooms

Ooh, chat rooms. Right now they're illegal on Scratch, but that's not stopping anyone…

when (Time starts v)
set [chars v] to [Every single keyboard character you are going to use]

when I receive [Clear write v]
set [End_string v] to [] //Clear all data on this variable
when I receive [encode (STR) v] //STR is the string you are going to encode. Use a custom block here.
set [Len_ v] to (length of (STR))
set [End_string v] to (join (End_string) (join (length of (Len_)) (Len_)))
set [Val v] to [] //End string (above) will contain the encoded information in the end.
set [Co v] to [1]
repeat (length of (STR))

set [Ci v] to (letter (Co) of (STR))
set [Co2 v] to [1]
repeat until <<(Ci) = (letter (Co2) of (chars))> or <(Co2) > (length of (Chars))>>
change [Co2 v] by (1)

end
if <(Co2) < [10]> then

set [Val v] to (join (Val) [0])
end
set [Val v] to (join (Val) (Co2))
end
set [End_string v] to (join (End_string) (Val))
when I receive [Read start thing (STR) v] // The decoding script decodes small parts at a time so different 
set [End_string v] to [] //pieces of information can be used in different places. Use this before a decoding script.
set [Co v] to [1]
when I receive [Decode (STR) v] //Decoding
set [Val v] to [] //This will contain all the decoded information.
repeat (letter (Co) of (STR))

change [Co v] by (1)
set [Val v] to (join (Val) (letter (Co) of (STR)))
end
set [Len_ v] to (Val)
set [Val v] to []
repeat (Val)

set [Co2 v] to (join (letter (Co) of (STR)) (letter ((Co) + (1)) of (STR)))
set [Val v] to (join (Val) (letter (Co2) of [chars]))
change [Co v] by (2)
end

I guess it's hard to understand. But hopefully this at least affects your progress in your chat room (whether it is good or bad)

It's obvious these scripts were from Griffpatch.

Last edited by Alberknyis (April 10, 2014 06:52:36)

atorubarov
Scratcher
10 posts

Chat Rooms

I am against it.
Scratch is so like a government.
hppavilion
Scratcher
100+ posts

Chat Rooms

atorubarov wrote:

I need help making a chat room.
By ciphering words to numbers then deciphering.
Keeping all the information in a cloud variable is what I can do, but I need help with the ciphering and deciphering.
Here are the steps: (Two version/methods, differences explained below)
1: Create a variable with an “alphabet,” or an index of every possible individual symblol
2: program it so that for each letter of input, it searches each letter (Letter (i) of (answer)) of the symbol index until there's a match
3: Add variable i to a numeralized variable (join (numeralized) (i)) (you'll need to set it up so if i is one numeral, it adds a zero to the begining of it)
4: reset i, repeat process until every letter is numeralized
5: A) Set numeralized to a cloud variable or B) Join a cloud variable and numeralized (also add some form of seperator symbol. I use § usually)
6: At the other end, A) Decrypt the cloud, add to list B) Decrypt the cloud, set item one of list to beginning of cloud, once it reaches the seperator add the next segment up to the next seperator to item 2 of list, etc.
7: A) Figure out a way for each person to get the message only once, so it doesn't add it every decryption cycle (for two person, you can just reset the chat. For a group, it'll be a bit harder) B) Skip this step
8: B-optional) Make it so that the items at the beginning of the cloud variable are removed while the items at the end are added. This is to restrict chat lenght.

Versions explained:
A is a chat similar to minecraft. When you say something, it is added to the list of everyone who is on. If someone joins, they will see the messages added only after they join. It only works for smaller numbers of people, because it would need to have time to decrypt it before someone else says anything (Note: You could add a workaround in which it sets the cloud to a normal variable then decrypts that, but you would either still run out of time if someone says something and it's set to local before you finish, or you could miss a message if it waits to add it to local until after it is finished decrypting and someone else says yet another thing first. You could work around this by adding a chat queue list, which would store items waiting to be decrypted any time someone writes a new message)
B This one stores every message ever sent in one massive cloud variable, unless you clear it or parts of it every so often. If a player joins, they will see every message ever sent automatically, and any message deleted by someone who you program to have the ability to do so will instantly be cleared from everyone's screen. It also allows message editing, if you add the code.
Anas10
Scratcher
24 posts

Chat Rooms

Alberknyis wrote:

Ooh, chat rooms. Right now they're illegal on Scratch, but that's not stopping anyone…

when (Time starts v)
set [chars v] to [Every single keyboard character you are going to use]

when I receive [Clear write v]
set [End_string v] to [] //Clear all data on this variable
when I receive [encode (STR) v] //STR is the string you are going to encode. Use a custom block here.
set [Len_ v] to (length of (STR))
set [End_string v] to (join (End_string) (join (length of (Len_)) (Len_)))
set [Val v] to [] //End string (above) will contain the encoded information in the end.
set [Co v] to [1]
repeat (length of (STR))

set [Ci v] to (letter (Co) of (STR))
set [Co2 v] to [1]
repeat until <<(Ci) = (letter (Co2) of (chars))> or <(Co2) > (length of (Chars))>>
change [Co2 v] by (1)

end
if <(Co2) < [10]> then

set [Val v] to (join (Val) [0])
end
set [Val v] to (join (Val) (Co2))
end
set [End_string v] to (join (End_string) (Val))
when I receive [Read start thing (STR) v] // The decoding script decodes small parts at a time so different 
set [End_string v] to [] //pieces of information can be used in different places. Use this before a decoding script.
set [Co v] to [1]
when I receive [Decode (STR) v] //Decoding
set [Val v] to [] //This will contain all the decoded information.
repeat (letter (Co) of (STR))

change [Co v] by (1)
set [Val v] to (join (Val) (letter (Co) of (STR)))
end
set [Len_ v] to (Val)
set [Val v] to []
repeat (Val)

set [Co2 v] to (join (letter (Co) of (STR)) (letter ((Co) + (1)) of (STR)))
set [Val v] to (join (Val) (letter (Co2) of [chars]))
change [Co v] by (2)
end

I guess it's hard to understand. But hopefully this at least affects your progress in your chat room (whether it is good or bad)

It's obvious these scripts were from Griffpatch.

i agrree, but as long as if the chat is safe

Powered by DjangoBB