May 12, 2025

 Thunkable: Coding Conditionals

0

Okay team, Muzukuke once again! We are jumping into a core coding skill, this time specifically for those of you using Thunkable to build your amazing apps.

Just like we discussed for App Inventor, our apps need to be smart! They need to make decisions based on what the user does or what’s happening in the app. The way we give apps this intelligence in Thunkable is by using

Conditionals. Let’s explore how this works.

Lesson Topic: Thunkable – Coding Conditionals

Part 1: Making Choices – What are Conditions?
Life is full of conditions and choices, right?

If the boda-boda prices surge during rush hour in Jinja town, then you might decide to wait or walk if it’s not too far.
If you receive an alert from your banking app about low balance, then you adjust your spending plans.
If the weather forecast on your phone shows heavy rain is expected this afternoon, then you remember to carry an umbrella or raincoat.
These “If… then…” decisions are based on Conditions (Is the price high? Is the balance low? Is rain expected?). You check the condition, see if it’s true or false, and act accordingly.
Our Thunkable apps need to do the exact same thing to be interactive and useful:

If a user enters the correct login details, then navigate them to the main screen.

If items in a shopping cart total more than 50,000 UGX, then maybe offer free delivery.
Conditionals are essential for building this logic.
 
Part 2: The Decision Blocks in Thunkable
In Thunkable, you’ll find the blocks for making decisions in the Control drawer in the Blocks editor. They look very similar to the App Inventor ones but use slightly different wording (like do instead of then).

The Basic if…do Block:
(Imagine the Thunkable ‘if do’ block here – looks like a C-shape)

How it works: You connect a condition block (something evaluating to true or false, e.g., app variable Score = 100 or WasButtonClicked = true) to the if slot.

If the condition is true, the blocks you place inside the do section will run.

If the condition is false, the app skips the blocks inside do and continues running any code after the if block.
Example: If app variable UserLoggedIn = true, do set WelcomeLabel’s Text to “Welcome Back!”

The if…do…else Block:
(Imagine the Thunkable ‘if do else’ block here)

How it works: This provides two paths for your code.

If the condition is true, the blocks in the do section run.

Else (if the condition is false), the blocks in the else section run.
Example (Login Logic):

The if…do…else if…do…else Block:
(Imagine the Thunkable ‘if do else if do else’ block here)

How it works: For checking multiple conditions sequentially.
Checks the first if condition. If true, runs the first do section and exits the entire block.

If false, checks the else if condition. If that’s true, runs the second do section and exits.
You can add more else if clauses or an else at the end using the blue gear icon on the block.
If none of the if or else if conditions are true, the final else section runs (if present).

Example (Checking User Input):

CRITICAL REMINDER: Order is key! The conditions are tested from top to bottom. The first one found to be true gets executed, and the rest are ignored for that specific event. Plan your checks logically!
 
Part 3: Let’s Code! The Counting Game in Thunkable (Activity – 20 mins)
Time for some hands-on practice with Thunkable conditionals!

The Game: Same as before – add numbers, try to hit exactly 100 to win, go over 100 and you lose.

Your Task using Thunkable:

Get the Starter Project: Open the link in the lesson materials for the Thunkable starter project. Click the “click to remix” button to make your own editable copy.

Use the Worksheet: Open the linked worksheet – it provides specific instructions for the Thunkable version.

Implement the Logic: In the Blocks tab, find the when Button Click event handlers for the number buttons. Inside these, after you update the app variable TotalScore, you’ll add conditional logic:
Use an if…do…else if…do…else block from the Control drawer.

Check: if app variable TotalScore = 100 do set result label to “You Win!”.
else if app variable TotalScore > 100 do set result label to “You Lose!”.
else do update the score display label with the current app variable TotalScore.

Try Your Best First! Work through the worksheet and try to build it. Debugging is part of learning!

Consult the Solution (If Needed): The lesson provides a link to uncover a possible solution if you get completely stuck or want to compare after you’re done.
 
Part 4: Take it Further (Challenge)
If you finish the main activity:

Add a Reset Button:

Drag a Button component onto your Thunkable screen, label it “Reset”.

In the Blocks editor, add a when ResetButton Click event.

Inside this event, set the app variable TotalScore back to 0.

Also, make sure to clear the text of the label that shows “Win” or “Lose”.
 
Part 5: Real-World Decisions (Reflection)
Let’s think about everyday conditions again. The lesson mentioned:
If cold -> wear jacket.
If phone dead -> charge it.
If sick -> doctor (else school/work).
If clothes dirty -> wash (else put away).
What other conditional choices do you make daily? Maybe related to transport (take a boda vs. taxi based on distance/cost?), food (if maandazi looks fresh, then buy?), or helping at home (if chores are done, then free time?). Discuss a few examples within your team.
 
Part 6: Quick Review (Key Terms)
Conditions: A situation or state checked by the app (e.g., variable = 5, input text is empty). Evaluates to true/false.

Conditionals statements or blocks: The Thunkable blocks (if do, if do else, etc.) used for decision-making.
if/else: The structure telling the app: If a condition is true, do this section. Else (if false), do the other section.
 
Part 7: More Thunkable Practice

The lesson provides a link to a helpful video specifically demonstrating conditionals in Thunkable within another simple app. Check it out if you want more examples!
https://youtu.be/RAtGL5GUmj0?si=paZ44dZwTBLBcr5V
 
Conclusion

Praise God / Well done! You’ve now grasped how to make your Thunkable apps make decisions using conditionals. This is a fundamental skill that separates static screens from truly interactive and intelligent applications. Understanding if, else if, and else is vital for your Technovation projects!

Your Mission: Get that Counting Game activity done in Thunkable. Remix the project, follow the worksheet, and build that logic. Tackle the challenge too!

The more you practice with these blocks, the more sophisticated your apps can become. Keep building, keep learning! Mweraba! (Goodbye for now!)
 

Leave a Reply

Your email address will not be published. Required fields are marked *