(☁ var) This article or section uses Cloud Data. Users who are New Scratchers or are using the Offline Editor cannot make projects using Cloud Data or use it in other users' projects. To use Cloud Data, the Scratcher status is needed and the Online Editor has to be used.

This page will show how to make a simple username cloud list.


Variables and Lists

Create two lists: one for characters (letters, numbers, etc.), and another for the players. The player list will be the only one shown in the final product, so a suitable name would be "Players".

Next, create another two variables. The names of these do not matter, because they will not show, but make sure they can be easily distinguished.

You also need 2 cloud variables. One is the encoded username, the other is the next available slot in the list, set to 1.

Character List

Next, add this script:

when flag clicked
delete all of [Characters v]
set [item v] to [1]
set [chars v] to [ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890-_]
repeat (( length of (chars)) + (1))
  add (letter (item) of (chars)) to [Characters v]
  change [item v] by (1)

Username Adding Script

Create the following script to encode a Scratcher's username.

when I receive [Add Username v]
set [Variable 1 v] to [1]
if <not <[Players v] contains (username)?>> then
if <not <(username) = [ ]>> then
repeat (length of (username))
find character (letter (Variable 1) of (username))::custom
change [Variable 1 v] by [1]
set [☁ CLOUD DATA v] to (join (☁ CLOUD DATA) [00])
replace item (☁ current slot) of [Players v] with (username)
if <not <[Players v] contains (username)?>> then
change [☁ current slot v] by (1)

Add the following definition hat; its code will be added later.

define find character (character)::custom

Use this script if manually adding names is necessary:

repeat (length of (name)) // "name" holds the username that someone want to add.
find character (letter (Variable 1) of (name)) ::custom
change [Variable 1 v] by [1]
set [☁ CLOUD DATA v] to (join (☁ CLOUD DATA) [00])

Define Find Character Script

Now, add the first define script. It should look like this:

// The below should have already been created.
define find character (character)
set [Variable 2 v] to [1]
repeat until <(item (Variable 2) of [Characters v] :: list) = (character)>
change [Variable 2 v] by (1)
if <(Variable 2) < [10]> then
  set [☁ CLOUD DATA v] to (join (☁ CLOUD DATA) (join [0] (Variable 2)))
  set [☁ CLOUD DATA v] to (join (☁ CLOUD DATA) (Variable 2))


Variables and Lists

Create five more normal variables. This tutorial names them as follows:

(data item)
(build username)

Main Script

Now, add this script:

when flag clicked
delete all of [Players v]
set [uv1 v] to [1]
set [uv2 v] to [2]
set [data item v] to [01]
repeat (450)
decode character::custom
wait (0.05) secs
if <(data item) = [ ]> then
broadcast (Add Username v)
stop [this script v]
broadcast (Add Username v)
Note Note: The number "450" in the repeat block does not have to be 450;
It can be anything, but just keep in mind that this number is the maximum amount of usernames that will be added to the Players list. If this number is 35 and a 36th Scratcher clicks the green flag and gets their username data saved then clicks the flag again, it will send duplicate data. Keep this number higher than the total views of the project.

Decoding Blocks

This is the last script. It is also the most complicated.

define decode character::custom
set [build username v] to [ ]
if <(☁ CLOUD DATA) = [ ]> then
stop [this script v]
repeat until <(decoded) = [00]>
set [data item v] to (join (letter (uv1) of (☁ CLOUD DATA)) (letter (uv2) of (☁ CLOUD DATA)))
set [decoded v] to (item (data item) of [Characters v])
set [build username v] to (join (build username) (decoded))
change [uv1 v] by (2)
change [uv2 v] by (2)
if <(join (letter (uv1) of (☁ CLOUD DATA)) (letter (uv2) of (☁ CLOUD DATA)))=()> then
stop [this script v]
add (build username) to [Players v]

See Also

Cookies help us deliver our services. By using our services, you agree to our use of cookies.