Discuss Scratch

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:

when green flag clicked
See? 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:
forever

end

This is the “forever” Function,Functions are scripts something like events,But they doing diffent things,You actually guessed what the forever function doing.

To make the say script forever,Just drag the block inside the forever function,It should be looking like this:
when green flag clicked
forever

say [Hello,Im <your name here> And im new to scratch!]
end
Walla! 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
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 clicked
Now 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) steps
Block 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 clicked
say [Owch!]
move (pick random (-10) to (10)) steps
Now 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

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 clicked
set [Punchs] to [0]
Soo thats the script now lets add the next block to our hit script!
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 <> then

end
This function will do something if theres something else.
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]> then
broadcast [Ragequit]



end
The 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:
when green flag clicked
set [Punchs] to [0]
if <(Punchs) = [10]> then
broadcast [Ragequit]
end
Then make the broadcast event,Which will be this script,You dont need showchases anymore so this is the script:
when I receive [Ragequit]
say [GHTSKJHSTGKHTGRAJGA] for (2) secs
hide
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


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!

Hello!
I'm TheAwesomeMaster: a middle school violist (someone who plays the viola), coder, artist, and writer! I also enjoy role-playing and helping out in the community.
| Profile | Wiki Page | Scratch String Orchestra | ᎪρᏂεℓ༏Ꮻ₪~ A Space Odyssey by Novakitty |
If you are reading this, comment “I have superpowers.” on my profile.
^._.^::control //This is Kallie. She is a certified siggy protector. She protects my siggy from kumquats.
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

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?

Scratch Team Member, kayak and pickleball enthusiast, cat caregiver.

This is my forum signature! On a forum post, it is okay for Scratchers to advertise in their forum signature. The signature is the stuff that shows up below the horizontal line on the post. It will show up on every post I make.
(credit to Za-Chary)



;
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)

guyalf1 wrote:

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

Check out my profile

First project: Flappy Parrot
First animation: 'Sus' among us

Follow me

Powered by DjangoBB