Skip to content

3. Loops

CosmologicalButter edited this page May 12, 2021 · 1 revision

Say you wanted to create a loop that outputs a number every second, like:

01 - 10
02 - 20
03 - 30
04 - 40
05 ...

This can be done by a loop. You can create a loop by making a create[loop] function, as ween below. This creates the loop that fires every second using the __TIME__

create[loop[increment{__TIME__('s')+1}]]
    par{name='loop'}

After you this, you'd need to create the number 01 in 01 - 10, this can be done via this script: This also dictates that the format has to be either 01 or 10.

create[num[1]]
    par{name='num1' , digit[format('0' , num[dig2] ;; num[dig1] , num[dig2])]}

The second number is created more easily by this script:

create[num[10]]
    par{name='num2'}

We then tell the script to execute:

loop('loop').run: //calls on loop 'loop' to run
    num[
        par{name='num1'} //+1s the first number
    ] + num[1]

    num[
        par{name='num2'}
    ] + num[10] //+10s the second number

    output[num['num1'] , '-' , num['num2']] //prints the output (02 - 20 and so on)
Clone this wiki locally