Skip to content

Control Flow

Conditionals

const x = 5;

if (x == 5) {
    print("x is 5!");
} elseif (x == 10) {
    print("x is 10!");
} else {
    print("x is something else!");
}

Numeric For Loop

// for (i = starting point, max value of i (value to stop at), increment(how much to increase i by every time))
for (i = 1, 5, 1) {
    print(i); // 1, 2, 3, 4, 5
}

Dictionary Iteration

const dict = {
    a: 5,
    b: 10
};

for (key, value in dict) {
    print(key, value);
}

Array Iteration

const arr = [1, 2, 3];

const _ip = ipairs(arr);
for (index, value in _ip)
{
    print(index, value);
}

While Loop

while (condition) {
    // ...
}

// example:
while (true) {
    // loop forever
}

let a = 1;
while (a <= 5)
{
    a = a + 1;
    print(a);
}