Coding Ireland STEM Report 2024 Have Your Say
Scratch
Intermediate
60 mins
125 points
What you need:
  • Computer/laptop

Username Generator

In this lesson you will create a robot that first asks you some questions and then generates a username for you based on your answers!

1 - Create a new Scratch project

Create a new Scratch project and delete the cat sprite.

2 - Add the Retro Robot sprite

We're going to use a robot sprite to ask you some questions. The answers to these will help make your username!

Once you've added the 'Retro Robot' sprite form the library, drag it to the middle of the stage area.


3 - Create a 'user name' variable

We will need to create a variable called 'user name' to store the text of our username as we build it.

When you create a variable, a small orange rectangle appears in the stage area that displays the current value of that variable. We don't need to this display so we're going to add the following code to hide it:

when green flag clicked hide variable [user name v]

4 - Say the instructions

Our robot is going to give the instructions for using the username generator. Add the following code at the bottom of the 'when green flag clicked' blocks of code:

when green flag clicked say [I am the random username generator robot!] for [5] secs say [To get a username, answer these questions...] for [5] secs


5 - Get the first letter of their name

The start of the username is going to be the first letter of the person's name. We can get this by asking the person what their name is and then taking the first letter of their answer. Add the following code at the bottom of the when clicked blocks of code:

when green flag clicked say [I am the random username generator robot!] for [5] secs say [To get a username, answer these questions...] for [5] secs // insert the new code below here ask [Whats your first name?] and wait set [user name v] to (letter (1) of (answer))



Join our club 😃

To view the remaining 6 steps and access hundreds of other coding projects please login or create an account.

Copyright Notice
This lesson is copyright of Coding Ireland. Unauthorised use, copying or distribution is not allowed.

Scratch is developed by the Lifelong Kindergarten Group at the MIT Media Lab. It is available for free at https://scratch.mit.edu
🍪 Our website uses cookies to make your browsing experience better. By using our website you agree to our use of cookies. Learn more