Vǫrðr Forge Steam page

Rûn Language

Rûn Values and Types

Every value in Rûn is one of a few kinds. Event scripts know two of them; programs know all of them.

Event scripts: numbers and text

An event script variable holds a number or a piece of text, decided by set: when the rest of the line reads as arithmetic it is a number, otherwise the words are text.

[use]
set gold_found 2 + 3
set greeting Well met, traveler

After it runs, gold_found is the number 5 and greeting is the text Well met, traveler. Text holds at most 63 characters. In a condition a text variable reads as 0, and a variable that was never set reads as 0 too.

Programs

number
A 32-bit floating point number. Whole numbers are exact up to 16777216; fractions carry about seven digits. int and float are other spellings of the same type.
text
Up to 159 bytes of UTF-8 text. string is another spelling.
toggle
On or off. Written true and false; printed on and off. Every comparison gives a toggle. bool is another spelling.
list
Values in square brackets, [2, 4, 8]. See below.
object
An engine object (Player, World, Camera ...), a foe from World.Enemy(i), a lake from Water.Find(name), or an instance of a struct your project declares. See Rûn Engine Objects.
nothing
What a function gives back when it returns no value. It prints as none and counts as false.

How values print

print writes each of its arguments with one space between. A whole number prints without a decimal point; any other number prints as an ordinary decimal with the fewest digits that give it back, at most seven significant digits. Joining a number to text with + writes it the same way.

print(7, 2.5, 1 / 3, 3.14159, 0.1 + 0.2)
print(true, false, 3 > 2)
print("text", [1, "two", true])
7 2.5 0.3333333 3.14159 0.3
on off on
text [1, two, on]

A large number prints in full, with its fraction:

print(12345.6, 1234.5, 100000)
12345.6 1234.5 100000

A value holds about seven significant digits, so a number of more digits than that prints rounded to them. Use round(x, places) to choose the places yourself. To show a number whole, round it first: print(round(12345.6)) prints 12346.

What counts as true

if and while take any value. A number or toggle is true when it is not 0, a piece of text is true when it is not empty, nothing is false, and a list or an object is true.

if (0) print("0 is true") else print("0 is false")
if ("") print("empty is true") else print("empty is false")
if ("no") print("any text is true")
if (!0) print("!0 is true")
0 is false
empty is false
any text is true
!0 is true

Mixing kinds

+ joins as text when either side is text. == and != compare as text when either side is text, and text is compared without regard to case. Every other operator wants numbers on both sides, and a toggle is not a number there.

print("hp " + 3.5 + " of " + 10)
print("Wolf" == "wolf", 5 == "5", true == 1)
hp 3.5 of 10
on on on
print(true + 1)
this arithmetic wants numbers on both sides

There is no function that turns text into a number. Keep numbers as numbers from the start.

Lists

A list is written with up to eight values between [ and ], and may mix kinds. list[0] is the first value and list.Count is how many there are. A list cannot be changed once made: make a new one instead.

stages = ["calm", "angry", "furious"]
print(stages[0], stages.Count, stages[stages.Count - 1])
calm 3 furious
stages = ["calm", "angry"]
print(stages[2])
index 2 is outside the list: it holds 2 items (0..1)

Declared types

A project may declare its own types (struct) and named values (enum) in assets/run/*.run; programs make them with New. See the Declarations part of Rûn Programs.