Discuss Scratch

pizza_king16
Scratcher
100+ posts

Username blocks?

Could some kind scratcher plz reveal to me how to use the username block? I’d be much obliged!
ResExsention
New Scratcher
1000+ posts

Username blocks?

pizza_king16 wrote:

Could some kind scratcher plz reveal to me how to use the username block? I’d be much obliged!

It basically stores the username of the person playing it. If you need to refer to the player you can use that.

For example, if I played your project, and you did this:

forever
if <(username) = [ResExsention]> then
say [Hi Res!]
else
say [Hi someone else!]
end
end
FateSealer
Scratcher
100+ posts

Username blocks?

If you write a toy operating system in Scratch, you may want the user to sign in (login) by requesting their “Name” and “Password”. Of course, you can use the “username” block to fill the “Name” of the user, and request the password only.
codeman1044
Scratcher
1000+ posts

Username blocks?

Block:
 (Username) 
How it works:
This block returns the username of a viewer. It returns the username along with an asterisk ( * ) if the viewer is a Scratch Team member. It returns empty if the viewer is not signed in. I believe it is case sensitive as well.
Usage:
Getting a username for an RPG
Cloud tracking*
Checking to see if the viewer is signed in (can be used to make sure that the game doesn't run into roadblocks if there isn't a username, and/or can be used to check if a user is an ST member)
Can be used for save files for games
Can be used for additions for if a friend is playing or something
Other things
Pros:
Tracks the username of a person
Cons:
None (unless you believe that the game is stalking you for your username)

*You're a new scratcher, so cloud variables won't work for you. They also won't work for people who aren't signed in. Also, cloud is hard to work with.
Rocket-Flier
Scratcher
100+ posts

Username blocks?

Here are a few uses of the username block:
Says hi to you:
say (join (join [Hello there, ] (username)) [!]) for (2) secs
Activates a test mode:
if <[admins v] contains (username) ?> then 
set [test mode v] to [on]


else
set [test mode v] to [off]
end
Gives a surprise to a certain user.
if <(username) = [pizza_king16]> then
broadcast [suprise v]
end
Counts the number of famous scratchers who view your project (Note: Wait until you are a scratcher to use cloud variables):
if <[famous scratchers v] contains (username) ?> then
change [☁famous views v] by (1)
end
pizza_king16
Scratcher
100+ posts

Username blocks?

How do you get it to save individual progress in a game?
codeman1044
Scratcher
1000+ posts

Username blocks?

If you use a save code in a game just add the username to it (encrypt it if needed)
Underseeker5
Scratcher
33 posts

Username blocks?

the username block checks the viewer's username so you can do stuff like this:
say (join [hello,] (username))
--Explosion--
Scratcher
1000+ posts

Username blocks?

It is easy to make a famous scratcher counter or provide an extra feature only avalible to a friend, but if you just click see inside and change the code around you can getthe extra feature yourself
--Explosion--
Scratcher
1000+ posts

Username blocks?

Thr username block reports the person using the project's username, for example if you played a game that reported your username, it would report pizza_king16 for you and staffordboys for me
ProCoer12
Scratcher
18 posts

Username blocks?

can someone tell me how to use the username block
ProCoer12
Scratcher
18 posts

Username blocks?

say [PLease Help] for (0) secs
EIephant_Lover
Scratcher
500+ posts

Username blocks?

ProCoer12 wrote:

can someone tell me how to use the username block
Instead of asking the same question as the original post, you can follow it to see what other people say by clicking “Follow Discussion,” the little blue box in the bottom right.

ProCoer12 wrote:

say [PLease Help] for (0) secs
Also, please don't blockspam.
Rkjartan
Scratcher
7 posts

Username blocks?

unfortunately this signature has been corrupted by an evil cat blockCAT BLOCKS WILL RULE
Oumuamua
Scratcher
1000+ posts

Username blocks?

Rkjartan wrote:

unfortunately this signature has been corrupted by an evil cat blockCAT BLOCKS WILL RULE

LOL!

Please do not spam!.
Thanks.
FoofJr
Scratcher
100+ posts

Username blocks?

So how does it work? It is just a reporter block that returns the name of the person running the project.

So you could use

say (join[hello ](username))

instead of

ask [what is your namer?] and wait
say (join[hello ](answer)

The latter means that people could put in inappropriate or offensive names. The former is constant at all times.


Probably a better feature for this is when you are debugging a project and don't want cheat codes.
Just make an if block checking if you are playing. I use this a lot because watching the same things play out is boring when you debug.

Hope this helps!
NastyPigletz
Scratcher
9 posts

Username blocks?

<(username) = (username)>

This block detects if the user is connected to your project or not. If
<not<(username) = (username)>

then the user is disconnected. This helps you to do cloud mutiplayer projects

Last edited by NastyPigletz (April 15, 2020 17:57:20)

deck26
Scratcher
1000+ posts

Username blocks?

NastyPigletz wrote:

<(username) = (username)>

This block detects if the user is connected to your project or not. If
<not<(username) = (username)>

then the user is disconnected. This helps you to do cloud mutiplayer projects
Not like that it doesn't! username will always be equal to itself.

Always happy to be proved wrong.
rontam
Scratcher
10 posts

Username blocks?

I don't Know how to put up Scratch blocks. Please help.
rontam
Scratcher
10 posts

Username blocks?

say (join [Hi ] (username)) for (2) secs

Powered by DjangoBB