Login

Fancade Wiki

Updated Loop.md (markdown)

... ...
@@ -1,4 +1,4 @@
1
The Loop block is used to run a script multiple times in the same frame. Often used for processing every element in a list.
1
The Loop block is used to run a script multiple times in the same frame. Often used for processing every element in a [[list|List Element]].
2 2
3 3
Inputs
4 4
- Start: The Loop blocks starts looping from the Start input.
... ...
@@ -12,4 +12,16 @@ Outputs
12 12
13 13
If you were to start the loop at 0 and stop it at 5, you would loop the script 5 times (Count) and the Counter outputs from 0 to 4 (End). Which shows that the Counter won't output the Stop value by the end of the loop, might want to keep that in mind.
14 14
15
[[/uploads/Screenshot_20210128-114243_Fancade.jpg]]
... ...
\ No newline at end of file
0
[[/uploads/Screenshot_20210128-114243_Fancade.jpg]]
1
2
## Example
3
4
Beginners often just place the script in the block that they want to process, in which every blocks of the same type would have the same script. For cases where the script is small or there aren't too many of the same type of blocks in a level, it won't cause much of a problem. Otherwise, you may easily run into a script limit while you're placing those blocks in a level.
5
6
We could put those blocks in a list and loop the script for every block, so that we could process every block we need with only one script, instead of having to add duplicates of that script.
7
8
In the example below, we're moving the blocks by (0, 0, 0.1) every frame.
9
10
[[/uploads/Screenshot_20210128-171605_Fancade.jpg]]
11
12
I mentioned previously that the Counter won't output the Stop value by the end of the loop. It won't be a problem because after we add the last block to a list, it increments the $Length variable by one. So, if the last block is assigned to index 4, $Length would equal to 5 which is exactly what the Stop input should be to account for every blocks.
... ...
\ No newline at end of file
Fancade Wiki