Loops
Tick loops
Section titled “Tick loops”In PPL, for updating every tick, pewpew.add_update_callback
is used. Hybroid Live wraps it in a tick
statement.
tick { Pewpew:Print("I am printed every tick!")}
It is possible to create a tick
statement with a time variable.
tick with time { Pewpew:Print(time .. " has elapsed")}
While loops
Section titled “While loops”In Hybroid Live and PPL while loops are discouraged. However, you can still use them if you want or need to.
while true { Pewpew:Print("Running infinitely and as fast as possible!")}
Repeat loops
Section titled “Repeat loops”Repeat loops are simple for
loops.
repeat 10 { Pewpew:Print("Hybroid Live is awesome!")}
It is possible to create a repeat
loop with an iteration variable.
repeat 10 with index { Pewpew:Print("This is " .. index .. "th iteration!") // -> This is 1th iteration!}
You can also specify the skip amount and the range, just like in Lua.
repeat by 2 from 4 to 10 with index { Pewpew:Print("This is " .. index .. "th iteration!") // -> This is 4th iteration!}
For loops
Section titled “For loops”for
loops are designed for advanced iterations.
let fruits = ["banana", "kiwi", "apple", "pear", "cherry"]
for index, fruit in fruits { Pewpew:Print(fruit .. " at index " .. ToString(index))}
You also have the option to ignore one of the variables by leaving a discard identifier (_
) in there.
let fruits = ["banana", "kiwi", "apple", "pear", "cherry"]
for _, fruit in fruits {// ignores the index Pewpew:Print(fruit)}
for index in fruits {// ignores the value Pewpew:Print(index)}