-
Notifications
You must be signed in to change notification settings - Fork 0
Loops & Conditionals
Instead of the traditional if / else found in other languages, Nova uses when to check a condition and otherwise to handle the alternative. These words are longer, so for ease of use, it is also valid to use wn for when and ow for otherwise instead of typing out the full length words. Make sure that when you have indentations they are 4-Space indentations not any more or else. Elifs (else and if in the same statement) are used by just doing whenwise or ww for short. The syntax follows the same as when and otherwise.
- Syntax:
when (condition) {
// code to run if true
} otherwise {
// code to run if false
}
- Example:
have timer = 0
when (timer == 0) {
put("Sequence complete.")
} otherwise {
put("Sequence interrupted.")
}
Loops in nova use while, it acts as a normal loop like in any other language, repeating a block of code as long as a specific condition remains true. This is useful for countdowns, processing lists, or waiting for specific states. You now MUST add a delay into loops or else the compiler will prevent it from compiling as a safeguard to prevent any issues.
- Syntax:
while (condition, delay between loops in ms) {
// code to repeat
}
- Example:
have timer = 5
while (timer > 0, 1000) {
put("T-minus: " + timer)
timer = timer -1
}
When writing conditions for when or while, you can use the following operators:
-
==: Equal to -
>: Greater than -
<: Less than -
>=: Greater than or equal to -
<=: Less than or equal to
Join our discord server for any support or questions that you need answered!
Link: