Lesson One: Flow
Before you can understand how behaviors work you need to understand how the game steps through the behaviors
The first part you probably already understand, Behaviors always start at Program Start and follow tethers. But what happens if the game is supposed to follow an outgoing tether node but there is no tether attached? Take the following behavior
DSCV2edLTY22LsC823u3931rA1Ms02qoTb32TvPu22VzV622kYQo3cWiBM2edLVY23vFVQ20Bu4X25sz0H1JM0nr22LjQt21ci0T00RtDtm
If you run the program after setting a location to the home parameter it will constantly send your unit to that location, the program never stops, even though there's no connection after the Move Unit instruction. This is because the default behavior if not in a loop is to if there is no connection to return to Program Start.
Loops and Flow
A Loop is a way of repeating a set of commands for a certain amount of times you can build a loop out of multiple instructions and tethers looping back onto themselves, but in this case we're referring specifically Loop type instructions located within the Flow category in the menu of instructions.
These nodes have two outgoing nodes one unlabeled and one labeled as done along with s single out put for a datatype. What happens when they are used is it will step through repeatedly each time pushing an datatype out and flowing through the top outgoing tether point as long as the tether connects to another instruction it will continues that chain until the tethers stop or it hits the Break instruction. If the tethers are not connected it won't go to Program Start but stop and go to the next thing in the loop and repeat the same process. When there are no more things in the loop it will go through the tether node labeled 'Done.'
Example:Items on the Ground
DSC8a2cbIPg0tMiaP3Z9WGe2EXWf838Ju6f0FnIKA1Wa5Rc3qW3gf2RP5AG10aeTo0jmU2a1hbLuO398Hmo4SiEN84ZZFpH27JgIS0Ow39N4ZZNhp1u4IYQ2F9AJW4YugqN0OIqU92xQGJQ4UENsP3WJO802Rfdxr0byKUf303d9Z22YUrO2zqPSO0NP4nO0eyehz1HaKCA1GN10z0qKlnv02aUit07hr3C3AbeEo06v7Rn2luLso27qWNe1mkYDF3uia7f2YLBq31Rl8Ps120zNF0dpymG3MqJ120SbVr50xyr8p3qEc9Z23bjd222qCAv1WcESI0gnq
Copy
In the above example the Copy Instruction is used to initialize the parameter to zero.
Copy takes data and copies it to an output usually a variable/parameter/register. In this case it looks like we're not copying anything but but even an empty field in Desynced is something, empty is actually a null data type coupled with zero, and since were about to count things we want a zero to add to.
Loop Entities(Range)
This is used to look for things within your units visual range (default is 15) and uses filters to narrow what your looking for. In this case the only filter used is dropped items this will look for items on the ground and piles of resources as well. For this loop you also need to set the range it's looking for you can set it as high as you want but it will only be able to see as far as the unit can which without other modules is 15, however you can set it a shorter range and it will limit what it returns. If you don't set it remember it's not nothing it acts as zero (range) so you will get no returns.
For every item it finds it will output an entity (not a data type but a set of data types) into the variable 'A' and then flow to the next instruction through the upper tether node.
Add
Add does exactly what it sounds like it adds one number to another number. You can use math functions on most data types maybe all due to them all having a number component. However math functions can behave differently when dealing with location data types.
Wait
Wait is only here to make it easier to see the count going up it set to wait 4 ticks there are 5 ticks in a second so it will wait each count one second before going into the next loop item.
Redo Loop
No more connections so outside of a loop it would go to Program start but since it's considered in a loop it will not restart but go to the next step in that loop.
End Loop
Once it has counted all dropped items in range it will go through the "Done" tether node.
Exit
If we wanted this behavior to constantly run we would not connect this tether to anything and it would go back to the beginning but in this case we want to only run once to do that the Exit instruction will stop the behavior running.
Note: if testing this behavior make sure there is something on the ground of it will not seem to work.