6.2.5 Creating values of Lists
After creating a list, an option will appear on the stage.
Figure 163: Adding a value to a list
This is what you can do when you are creating values in Scratch. There is a second option that allows you to import data from your computer. Scratch reads the “tab delimited” format, which implies that you must convert your data to that format.
Here are the guidelines of how you can convert the spreadsheet into “tab delimited” format.
- Copy and paste the data into a Notepad file. Open the notepad file and copy from the file you have pasted the data there. Afterwards, you will need to save and import to the Scratch.
Figure 164: Pasting data into a Notepad file
2. The second option is to convert the file into “tab delimited” format.
- Right click on the file
- Click on “Save as”
- Choose a location where to save the file
- Choose the file format to be “tab delimited” and then click OK
|
|
Figure 165: Convert a file into "tab delimited" format
After converting the file into “tab delimited” format, upload to the Scratch choose which column that holds the data you want to use.
Data is stored into variables to be given as values for any set condition. To understand how data is used, you need to start with variables. They are just ways to name and store data.
For example, if you had a game and wanted to keep a score, you would create a variable called score. You should always initialise variables.
|
|
Figure 166: Setting the score to 0
Figure 167: The Sprite reading the score for 2 seconds
Variables don't have to store just numbers they can also store letters and words. To make it a word or letters, you only need to replace the score with any letter or word that you want.
Figure 168: The Sprite showing the score
Literally, this is how you can use data and variables and it is more applicable in creating games and stories. We have seen how to use variables and data in creating stories in the previous modules. In this module, we are going to look at how we can use variables and data in building games.