On Collision With Do: Difference between revisions

From StarLogo Nova Wiki
(Created outline)
(duplicate file already uploaded)
 
(20 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{#vardefine:ocwd|<code>on collision with [▼] do</code>}}
<languages/>
<translate>


{{#var:ocwd}} is a [[code block]] part of the [[detection]] drawer.
<!--T:1-->
<section begin="image"/>[[File:On Collision With Do Block.png|alt=The on collision with do block|thumb]]<section end="image"/><p id="tooltip">Tells the "owner" of the block what to do when it bumps into an agent of the selected breed. The “owner” is an agent of the breed whose page is where this collision block is put.</p>


== Usage ==
<!--T:8-->
<section begin="name" />'''{{Block|on collision with [▼] do}}'''<section end="name" /> is a code block from the [[Detection]] drawer.


=== Syntax ===
<!--T:2-->
==Usage==
{{Block|on collision with [▼] do}} begins the execution of a [[stack]] of code when a [[collision]] is detected with a specific type of agent denoted in the drop down selector. The agent collided with is known as the "collidee". This agent can be referenced using the {{Block|l|collidee}} block.


<!--T:3-->
==Syntax==
[[File:On Collision With Do Nums.png|right|alt=On Collision With Do|thumb]]
<!-- <code>on collision with [Dropdown: Type of Agent] do [code]</code> -->
Inputs:
#a breed from the dropdown menu
#relevant code


[[Category:Detection]][[Category:Code Block]]
==Example== <!--T:9-->
 
<!--T:10-->
[[File:collidee_example.gif|alt=On Collision With Do example gif|thumb]]
[[File:on_collision_with_do_example.png|alt=On Collision With Do example code|thumb]]
 
<!--T:11-->
When the fish prey agents collides with the whale predator agent (i.e. they have the same x, y, and z coordinates) the prey agent deletes itself. This interaction makes it appear as if the predator eats the prey.
 
<!--T:4-->
==Nuances==
{{Block|on collision with [▼] do}} cannot be used as a [[conditional]] such as {{Block|l|if}}. {{Block|on collision with [▼] do}} must begin a [[stack]] of code.
 
<!--T:5-->
==Related Blocks==
*{{Block|l|collidee}}
 
<!--T:6-->
[[Category:Detection]]
[[Category:Code Block]]
</translate>

Latest revision as of 15:34, 16 August 2023

Other languages:
The on collision with do block

Tells the "owner" of the block what to do when it bumps into an agent of the selected breed. The “owner” is an agent of the breed whose page is where this collision block is put.

on collision with [▼] do is a code block from the Detection drawer.

Usage

on collision with [▼] do begins the execution of a stack of code when a collision is detected with a specific type of agent denoted in the drop down selector. The agent collided with is known as the "collidee". This agent can be referenced using the collidee block.

Syntax

On Collision With Do

Inputs:

  1. a breed from the dropdown menu
  2. relevant code

Example

On Collision With Do example gif
On Collision With Do example code

When the fish prey agents collides with the whale predator agent (i.e. they have the same x, y, and z coordinates) the prey agent deletes itself. This interaction makes it appear as if the predator eats the prey.

Nuances

on collision with [▼] do cannot be used as a conditional such as if. on collision with [▼] do must begin a stack of code.

Related Blocks