If: Difference between revisions

From StarLogo Nova Wiki
(updates from Blockument)
(duplicate file already uploaded)
 
(One intermediate revision by the same user not shown)
Line 24: Line 24:
#a comparative statement block ([[Special:MyLanguage/Equals|=]] statements, [[Special:MyLanguage/Greater Than|>]] statements, [[Special:MyLanguage/Not|not]] statement, [[Special:MyLanguage/And|and]]/[[Special:MyLanguage/Or|or]] statements)
#a comparative statement block ([[Special:MyLanguage/Equals|=]] statements, [[Special:MyLanguage/Greater Than|>]] statements, [[Special:MyLanguage/Not|not]] statement, [[Special:MyLanguage/And|and]]/[[Special:MyLanguage/Or|or]] statements)


==Example==
==Example== <!--T:23-->


[[File:if_example.gif|alt=If example gif|thumb]]
<!--T:24-->
[[File:key_held_example.gif|alt=If example gif|thumb]]
[[File:if_example.png|alt=If example code|thumb]]
[[File:if_example.png|alt=If example code|thumb]]


<!--T:25-->
This is a game in which the frog attempts to catch flies. The player can move the frog using the arrow keys on the keyboard. The program can process this input using the if block in conjunction with [[Special:MyLanguage/Key Held?|key held?]] or [[Special:MyLanguage/Key Typed?|key typed?]].
This is a game in which the frog attempts to catch flies. The player can move the frog using the arrow keys on the keyboard. The program can process this input using the if block in conjunction with [[Special:MyLanguage/Key Held?|key held?]] or [[Special:MyLanguage/Key Typed?|key typed?]].



Latest revision as of 16:00, 16 August 2023

Other languages:
The if block

Test for something. If true, then the agent follows the commands attached to the hook.

if [_] is a code block part of the Logic drawer.

Usage

if [_] takes in comparative statements from the Logic drawer to test for a condition. The agent will only follow commands attached to the hook if the statement is true.

Syntax

The If Block

Inputs in this block:

  1. a comparative statement block (= statements, > statements, not statement, and/or statements)

Example

If example gif
If example code

This is a game in which the frog attempts to catch flies. The player can move the frog using the arrow keys on the keyboard. The program can process this input using the if block in conjunction with key held? or key typed?.

Nuances

Related Blocks