Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Save Codes
- The-executer
- Scratcher
21 posts
Save Codes
Lets look into the code for saving levels if you have 3 levels
This is an idea of what the code should look likeL
Variables
username_level -cloud data
username -This has already been created in the sensing blocks
lists
already been here?
when I recieve level 1
“make this your level one costume”
set username_level to 1
when I recieve level 2
“make this your level two costume”
set username_level to 1
when I recieve level 3
“make this your level third costume”
set username_level to 1
when ^green flag click
if
username = not item any of “already been here?”
then set username_level to level 1'
add username to “already been here?”
else
if username_level =2
broadcast level 2
else
if username_level =3
broadcast level3
When ^green flag click
forever
if “end of level 1”
set username_level to 2
else
if “end of level 2”
set username_level to 3"
How does the code know if it's the end of the level?
- It doesn't and somehow you must find what causes your program to advance to the next level
E.G f my name was bill
and I already played this game and I was level 2
already been here?
bill
bill username_level =2
That's his personal variable
*Please note that cloud data can only store variables NOT letters
So this is wrong code!!!
Do not copy this code below
Set username_level to username
This is just for levels so for the rest you will have to do
If you have any problems please go to my page
and tell me
This is an idea of what the code should look likeL
Variables
username_level -cloud data
username -This has already been created in the sensing blocks
lists
already been here?
when I recieve level 1
“make this your level one costume”
set username_level to 1
when I recieve level 2
“make this your level two costume”
set username_level to 1
when I recieve level 3
“make this your level third costume”
set username_level to 1
when ^green flag click
if
username = not item any of “already been here?”
then set username_level to level 1'
add username to “already been here?”
else
if username_level =2
broadcast level 2
else
if username_level =3
broadcast level3
When ^green flag click
forever
if “end of level 1”
set username_level to 2
else
if “end of level 2”
set username_level to 3"
How does the code know if it's the end of the level?
- It doesn't and somehow you must find what causes your program to advance to the next level
E.G f my name was bill
and I already played this game and I was level 2
already been here?
bill
bill username_level =2
That's his personal variable
*Please note that cloud data can only store variables NOT letters
So this is wrong code!!!
Do not copy this code below
Set username_level to username
This is just for levels so for the rest you will have to do
If you have any problems please go to my page
and tell me
- Discussion Forums
- » Help with Scripts
- » Save Codes