In other languages

Help the wiki!

The Scratch Wiki is made by and for Scratchers. Do you want to contribute?

Learn more about joining as an editor!

See discussions in the Community Portal

Username (block)

Username
2.0 Username block.png
Category Sensing
Type Reporter
Introduced in 2.0

The Username block is a sensing block and a reporter block. It reports the username of the user viewing the project, which can be used for saving progress in a project, either with a variable encoder or cloud lists (once they are released with string-storage capabilities), as well as other purposes. If no user is signed in, this block returns the empty string.

Controversy

The warning.

Originally, the Scratch Team was reluctant to add this block because it could compromise users' privacy.[1] They started with the User ID block, which gave an anonymous but effective way of recognizing users for a specific project. However, they eventually decided to replace it with this block because it is easier for beginners to understand and was so frequently requested.

As a safety measure, all projects that sense your username have warnings attached. If one wants to be anonymous, log out before viewing the project. However, it was complained that the message was too exaggerated, because of the usage of the term "hide your identity".[2] Alongside, the warning appears if the backpack had a script with the username block, no matter if the project had a username block or not.[3]

Example uses

  • Saying hi to the user viewing the project
say (join [Hi, ] (username))
  • Checking if the user has visited before, using Cloud Data
Warning Note: Cloud lists have not come out yet, so you would have to make your own cloud list.
if <not <[☁ visitors v] contains (username)>> then
  add (username) to [☁ visitors v]
else
  say [Welcome back again!]
end
  • Checking if the viewer is logged in
when gf clicked
if  <(username) = []> then//a logged off user reports a blank response
say [Hi new user!] for (2) secs 
  • Creating a high score list
  • An "admin" list in a safe chat
when gf clicked
if <[admins v] contains (username)?> then//The "admins" list will likely have the project owner, all of their alternate accounts, and possibly all Scratch Team members
broadcast [admin v]

See Also

  • User ID — this block's predecessor

References

  1. #p1272791 https://scratcharchive.asun.co/forums/viewtopic.php?id=98376#p1272791
  2. http://scratch.mit.edu/discuss/topic/32509/
  3. https://scratch.mit.edu/discuss/topic/154048/
  • This page was last modified on 2 July 2017, at 17:52.