DocsBuilt-in functions
Maths
Numbers work with + - * / % in any value. These functions do the rest.
$sum
$sum[a;b...]
a + b + ...
sum.naja
$print[$sum[1;2;3;4]] najova run sum.naja
10
$sub
$sub[a;b...]
a - b - ...
sub.naja
$print[$sub[100;30;5]] najova run sub.naja
65
$mul
$mul[a;b...]
a * b * ...
mul.naja
$print[$mul[2;3;4]] najova run mul.naja
24
$div
$div[a;b...]
a / b / ...
div.naja
$print[$div[100;8]] najova run div.naja
12.5
$mod
$mod[a;b]
What is left of a after taking b away as often as it goes (a % b).
mod.naja
$print[$mod[17;5]]
$print[Is 8 even? $checkCondition[$mod[8;2] == 0]] najova run mod.naja
2 Is 8 even? true
$round
$round[number] or $round[number;places]
The number rounded (to some places after the point).
round.naja
$print[$round[3.14159]]
$print[$round[3.14159;2]] najova run round.naja
3 3.14
$floor
$floor[number]
The number rounded down.
floor.naja
$print[$floor[7.9]] najova run floor.naja
7
$ceil
$ceil[number]
The number rounded up.
ceil.naja
$print[$ceil[7.1]] najova run ceil.naja
8
$abs
$abs[number]
The number without its minus.
abs.naja
$print[$abs[-12]] najova run abs.naja
12
$min
$min[a;b...]
The smallest of the numbers.
min.naja
$print[$min[8;3;5]] najova run min.naja
3
$max
$max[a;b...]
The biggest of the numbers.
max.naja
$print[$max[8;3;5]] najova run max.naja
8
$random
$random, $random[to] or $random[from;to]
A random number: 0 to 1, or a whole number from 1 (or from) to to.
random.naja
$let[roll;$random[1;6]]
$print[You rolled a number from 1 to 6: $checkCondition[$get[roll] >= 1 && $get[roll] <= 6]] najova run random.naja
You rolled a number from 1 to 6: true
$number
$number[text]
The text as a number (nil when it is not one).
number.naja
$print[$number[42] + 1]
$print[$number[hello]] najova run number.naja
43 nil
$checkCondition
$checkCondition[condition]
true or false: whether the condition holds.
checkCondition.naja
$let[age;20]
$print[Adult: $checkCondition[$get[age] >= 18]] najova run checkCondition.naja
Adult: true