Navigation

    CreatiCode Scratch Forum

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • CreatiCode

    The "If < > Then" Block

    2D Blocks
    1
    1
    265
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • info-creaticode
      CreatiCode last edited by admin

       

      Prerequisite

      • Working with Blocks

       

      Description

      The “If <> then” block is a C block in the control category.


       

      How does this block work?

      This block runs the blocks inside its mouth if the condition is true. If the condition is false, it ignores the blocks inside it and continues to the blocks below it.


       

      The condition is checked only once

      The “If <> then” block checks its condition only once.


       

      Nested If <> then Blocks

      If you put one “If <> then” block inside the other, they become “Nested”.

      You can use Nested “if <> then” blocks when you want to check another condition when the first condition turns out to be true.

      For example, as shown below, the first “If” block checks if the sprite is touching the “Start” sprite or not. if it is “true” then the second “If” block checks if the “x-position” is greater than 10. The sprite will say “Game started” when both conditions are true.


       

       

      Multiple If <> then Blocks

      You can stack multiple “If <> then” blocks together to check multiple conditions at the same time.

      For Example, as shown below, if the score is less than or equal to “5”, the sprite will say “I’m sad”; if the score is greater than or equal to “10”, the sprite will say “I’m happy”.


       

      1 Reply Last reply Reply Quote 0
      • First post
        Last post