Discuss Scratch

LB102710
Scratcher
12 posts

Operators and How Can They Be Used

Hey everyone!
Apparently I've been posting my tutorials on the wrong forum, thanks to whoever pointed that out. I've been posting on the Help With Scripts forum. Anyways, I'm here to teach you guys about how operators can be used. If you don't know, operators are very helpful. I'll be going over the ones that could be most helpful and easiest to use (for me at least.) Anyways, operators are true or false statements in codes and could also be used for math equations. Here's an example:
when green flag clicked
if <(foo) = [1]> then
go to [ random position]
end
So what this does is if ‘foo’ = 1, then the sprite will go to a random position.
Here is the final example. Create a new project and keep the cat sprite for this part. Then create a new variable named ‘Cat’. After that, then copy this code:
when green flag clicked
set [ Cat] to [0]
wait (1) secs
set [ Cat] to [1]
if <[Cat] = [1]> then
go to x: (100) y: (0)


else
go to x: (-100) y: (0)
end
And there you go! What this code does is when the green flag is clicked, it will set ‘Cat’ to 0. Then, it will set to 1, the if-then-else block will run after that, and if the statement is true, the sprite will go to x:100 y:0. If the statement is false, then the sprite will go to x: -100 y:0
That's all for today, bye everyone!
Paddle2See
Scratch Team
1000+ posts

Operators and How Can They Be Used

Hello! It's great that you want to help out other Scratchers. However, I think we have enough guides in the forums at the moment. Please feel free to welcome new Scratchers on the group welcoming topic or on individual topics created by New Scratchers.

Other places that can always use more helpful Scratchers like you, are the "Help With Scripts“ and ”Questions About Scratch" areas - please use them as designed, by responding to topics created by folks with problems to solve

Finally, a really good place for Scratch guides is the Scratch Wiki - check it out and see if it's something you might like to work on. They have a number of guides - and great organization.

Powered by DjangoBB