DocsGuides
Values and names
A value is a number, some text, true, false, nil (nothing), a list or a table. Give a value a name to use it again.
Names
Make a name with $let, change it with $set, and read it with $get.
$let[coins;50]
$set[coins;$get[coins] - 20]
$print[Coins left: $get[coins]]Coins left: 30
A name made inside a block or a function belongs to it. Once the block ends, the name is gone.
$if[true]
$let[secret;42]
$endif
$print[$get[secret]]inside.naja:4: There is no name secret here; make it first with $let[secret;value].Maths
When a whole value is maths, Najova works it out. You can use + - * / %, brackets, and comparisons like >=. If anything in the value is plain text, the whole value stays text.
$let[price;4]
$print[$get[price] * 3]
$print[Three cost $get[price] * 3]
$print[Three cost $mul[$get[price];3]]12 Three cost 4 * 3 Three cost 12
Text
Spaces at the start and end of a value are dropped. To keep them, put the whole value in quotes. To use ;, [, ] or $ in text, put \ before it.
$let[padded;" wide "]
$print[Size: $count[$get[padded]] letters]
$print[Prices start at \$5\; delivery is free]Size: 10 letters Prices start at $5; delivery is free
Lists and tables
A list keeps values in order. Its first item is number 1. A table finds values by their keys. Read a table's value with a dot: $get[player.name].
$let[bag;$list[sword;rope]]
$add[$get[bag];lamp]
$print[$count[$get[bag]] items: $get[bag]]
$let[player;$table[name;Ari;gold;12]]
$set[player.gold;$get[player.gold] + 5]
$print[$get[player.name] has $get[player.gold] gold]3 items: [sword; rope; lamp] Ari has 17 gold
See Lists and tables for every function that works on them.