If: Difference between revisions
No edit summary |
(duplicate file already uploaded) |
||
(5 intermediate revisions by the same user not shown) | |||
Line 6: | Line 6: | ||
<!--T:15--> | <!--T:15--> | ||
<section begin=image/>[[File:If.png|alt=The if block|thumb]]<section end=image/> | <section begin=image/>[[File:If.png|alt=The if block|thumb]]<section end=image/><p id="tooltip">Test for something. If true, then the agent follows the commands attached to the hook.</p> | ||
<!--T:22--> | |||
<section begin=name/>'''<code>if [_]</code>'''<section end=name/> is a [[code block]] part of the [[Logic]] drawer. | <section begin=name/>'''<code>if [_]</code>'''<section end=name/> is a [[code block]] part of the [[Logic]] drawer. | ||
Line 12: | Line 14: | ||
<!--T:17--> | <!--T:17--> | ||
<code>if [_]</code> 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== <!--T:18--> | ==Syntax== <!--T:18--> | ||
<!--T:19--> | <!--T:19--> | ||
[[File:If Nums.png|right|alt=The If Block|thumb]] | |||
<!-- <code>if [Insert: Condition]</code> --> | <!-- <code>if [Insert: Condition]</code> --> | ||
Inputs in this block: | Inputs in this block: | ||
#a comparative statement block ( | #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== <!--T:23--> | |||
<!--T:24--> | |||
[[File:key_held_example.gif|alt=If example gif|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?]]. | |||
==Nuances== <!--T:20--> | ==Nuances== <!--T:20--> |
Latest revision as of 16:00, 16 August 2023
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
Inputs in this block:
Example
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?.