Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Basic Scripting Tutorial:Specally for new scratchers :D (MORE TUTORIALS COMING)
- guyalf1
- Scratcher
9 posts
Basic Scripting Tutorial:Specally for new scratchers :D (MORE TUTORIALS COMING)
Hello,This is a tutorial for new scratchers,A basic tutorials show basic scripts,blocks and more!
1. Your first script:Saying Hello,Im <your name> And im new to scratch,With some cool effects.
Okay,Start out by getting a start block,How to get a start block? go to the events category at the block list,then get the “when green flag clicked” block,Its a block named “ Event block ”
Thats how it should look like:
Lets combine the 2 blocks togther!
Drag the blocks 1 under 1 to do the speaking script!
Congrats,You did your first script!
But… As you can see.. Its only do it for some seconds… Lets make it do forever!
Get another block form the category “control” and get this block:
To make the say script forever,Just drag the block inside the forever function,It should be looking like this:
Lets garb again the “when green flag clicked” and the “forever functions” and we getting another block form looks will look like this:
Waila! We did it! Congrats on making your first script!
2.Medium advancement blocks and scripts:if < > then function,Variables,Broadcast messages,movments,more events and operators
So… Lets get a little advanced we will make a script that if you click on the sprite,We will punch him and he will say owch! and if it reach 10 hits it will ragequit and get invisible.
As told..You have to get the green flag,That will start script And now lets do the new thing were going to learn,Named,VARIABLES! Variables are the main stuff for scoreboards,score etc. We going to do the esay use now,That if he get hit by getting clicked (xD lol we click him and he get punched) and it also will can count the hits! Go to the data category and make a new variable by clicking on “make new variable” Lets call our variables “Punchs” Well after you create the “punchs” variable it will arrive on your background screen.Put it where you want by dragging it.
After you took care with those,Lets start scripting,Get a new event named “When sprite clicked” on events category,It should look like this:
Block 1:
Now drag everything and if you want to do a random number just drag the pick random -10 to 10 into the number at move 10 steps
It should look like this:
Go to the category “data” where you made the variable,And get this block:
Now…Lets make another thing! Lets add it to our variable thing,And get ready,Were learning a new function! Meet the function:
As you can see theres a little square with 2 trinagles on the middle of the brick. This is the output. Now what we can do with the if_then function….Hmm…I know! Lets make it rage if it reachs 10 hits!
Add the function to the variable script,And now lets start scripting into this function
Start Scripting the if_then function,Like last time,Garb in the output the next script and start scripting the function,But we dont need,We can do a faster way named broadcast scripts,It will message the server to do something after or when it will do something else.
COMING SOON: Tutorial 3: if_then_else function,Lists,Custom blocks and advanced way of variables
Hope i helped you learn on scratch!
1. Your first script:Saying Hello,Im <your name> And im new to scratch,With some cool effects.
Okay,Start out by getting a start block,How to get a start block? go to the events category at the block list,then get the “when green flag clicked” block,Its a block named “ Event block ”
Thats how it should look like:
when green flag clickedSee? Now then you want your charater to say something,Then get a block in the “looks” in the look category looks like this:
say []
Lets combine the 2 blocks togther!
Drag the blocks 1 under 1 to do the speaking script!
when green flag clicked
say [Hello,Im <your name here> And im new to scratch!]
Congrats,You did your first script!
But… As you can see.. Its only do it for some seconds… Lets make it do forever!
Get another block form the category “control” and get this block:
foreverThis is the “forever” Function,Functions are scripts something like events,But they doing diffent things,You actually guessed what the forever function doing.
end
To make the say script forever,Just drag the block inside the forever function,It should be looking like this:
when green flag clickedWalla! Lets test the script out! Oh yes,Its work! Now you “really” made your first script,Now we spoke about effects right? So lets make the effect colourchanging! It would be a nice idea
forever
say [Hello,Im <your name here> And im new to scratch!]
end
Lets garb again the “when green flag clicked” and the “forever functions” and we getting another block form looks will look like this:
change [color] effect by (25)This block will have the ablity to change your colour effect ,now lets combine everything toghter,Put the “when green flag clicked” on the “forever” function,And drag in the effect block and it will look like this:
when green flag clicked
forever
change [color] effect by (25)
end
Waila! We did it! Congrats on making your first script!
2.Medium advancement blocks and scripts:if < > then function,Variables,Broadcast messages,movments,more events and operators
So… Lets get a little advanced we will make a script that if you click on the sprite,We will punch him and he will say owch! and if it reach 10 hits it will ragequit and get invisible.
As told..You have to get the green flag,That will start script And now lets do the new thing were going to learn,Named,VARIABLES! Variables are the main stuff for scoreboards,score etc. We going to do the esay use now,That if he get hit by getting clicked (xD lol we click him and he get punched) and it also will can count the hits! Go to the data category and make a new variable by clicking on “make new variable” Lets call our variables “Punchs” Well after you create the “punchs” variable it will arrive on your background screen.Put it where you want by dragging it.
After you took care with those,Lets start scripting,Get a new event named “When sprite clicked” on events category,It should look like this:
when this sprite clickedNow lets make it say owch and move randomly! Add the say block we used in last script and then go to the category “Operators” and those 2 blocks:
Block 1:
move (10) stepsBlock 2:
(pick random (-10) to (10))In the script change the 1 into -10
Now drag everything and if you want to do a random number just drag the pick random -10 to 10 into the number at move 10 steps
It should look like this:
when this sprite clickedNow good,Oh wait! We forgot the variables! Lets make another script that if you activate all scripts right now its will setup the variable and set it to 0 when beginning script
say [Owch!]
move (pick random (-10) to (10)) steps
Go to the category “data” where you made the variable,And get this block:
set [Punchs] to [0]Mix this togther on the script:
when green flag clickedSoo thats the script now lets add the next block to our hit script!
set [Punchs] to [0]
change [Punchs] by (1)This block will add punchs score by 1,Lets add this to our script:
when this sprite clicked
say [Owch!]
move (pick random (-10) to (10)) steps
change [Punchs] by (1)
Now…Lets make another thing! Lets add it to our variable thing,And get ready,Were learning a new function! Meet the function:
if <> thenThis function will do something if theres something else.
end
As you can see theres a little square with 2 trinagles on the middle of the brick. This is the output. Now what we can do with the if_then function….Hmm…I know! Lets make it rage if it reachs 10 hits!
Add the function to the variable script,And now lets start scripting into this function
Start Scripting the if_then function,Like last time,Garb in the output the next script and start scripting the function,But we dont need,We can do a faster way named broadcast scripts,It will message the server to do something after or when it will do something else.
if <(death) = [10]> thenThe event block (broadcast ragequit) Will be the activator of the script,Lets contiune! Garb the function script into the variable script,It should look like this:
broadcast [Ragequit]
end
when green flag clickedThen make the broadcast event,Which will be this script,You dont need showchases anymore so this is the script:
set [Punchs] to [0]
if <(Punchs) = [10]> then
broadcast [Ragequit]
end
when I receive [Ragequit]And you done! Oh and secretly…You made your first game. Its based of a game named “Punch your boss” Then you made the scratch editon :c
say [GHTSKJHSTGKHTGRAJGA] for (2) secs
hide
COMING SOON: Tutorial 3: if_then_else function,Lists,Custom blocks and advanced way of variables
Hope i helped you learn on scratch!
if <I helped you> then
Dont forget to leave me a feedback and follow me :D
end
- TheAwesomeMaster
- Scratcher
1000+ posts
Basic Scripting Tutorial:Specally for new scratchers :D (MORE TUTORIALS COMING)
This is a really nice guide! I like how you use the Scratch blocks feature to show how to make the scripts.
I would suggest using the bold, and big text features to separate each step, or each different script/thing that scratchers could make.
Scratch on!
I would suggest using the bold, and big text features to separate each step, or each different script/thing that scratchers could make.
Scratch on!
- Paddle2See
- Scratch Team
1000+ posts
Basic Scripting Tutorial:Specally for new scratchers :D (MORE TUTORIALS COMING)
Fun stuff! But the Say block you are using there
actually *will* show forever - without any need for the Forever block. Maybe you were thinking of the
block instead?
say [Hello, this will show forever or until replaced by different Say stuff]
actually *will* show forever - without any need for the Forever block. Maybe you were thinking of the
say [This will only show for 2 seconds] for (2) secs
block instead?
- guyalf1
- Scratcher
9 posts
Basic Scripting Tutorial:Specally for new scratchers :D (MORE TUTORIALS COMING)
Oh yeah you right,Thanks for reminding me,Ill change that later.
- reddrian
- Scratcher
8 posts
Basic Scripting Tutorial:Specally for new scratchers :D (MORE TUTORIALS COMING)
when green flag clicked
set [Punchs v] to [0]
if <(Punchs) = [10]> then
broadcast [Ragequit v]
end
You need to use the forever loop because the if <> will only check once, so the script will be like this:
when green flag clicked
set [Punchs v] to [0]
forever
if <(Punchs) = [10]> then
broadcast [Ragequit v]
end
end
- Discussion Forums
- » Help with Scripts
- » Basic Scripting Tutorial:Specally for new scratchers :D (MORE TUTORIALS COMING)