Vǫrðr Forge Steam page

Rûn Language

Rûn Quick Tour

The whole language on one page, with each idea shown in both kinds of script. Each part links to the chapter that says everything about it.

An event script

An event script is a file in assets/events with sections in square brackets. The world calls a section by name; its lines run from the top, one verb each.

# assets/events/tour_sign.run: a sign that counts its readers
[use]
add readers 1
say Readers so far: {readers}.
if readers >= 3
  flag set tour_sign_famous
Readers so far: 1.

add readers 1 makes the variable readers the first time and adds 1 each time after; every event script sees it and the save keeps it. Indented lines belong to the if above them. See Line Scripts and Rûn Statements and Control Flow.

A program

A program is a file in assets/scripts written with braces. It declares variables with a type, has functions, and calls the engine's objects.

number total = 0
for (number i = 1; i <= 4; i = i + 1) {
    total = total + i
}
print("one to four make", total)
one to four make 10

See Rûn Variables and Scope and Rûn Statements and Control Flow.

A random number and a branch on it

In an event script, rand(51) is a whole number from 0 to 50:

[use]
set luck rand(51)
if luck < 10
  say Unlucky: {luck}.
else
  say Lucky: {luck}.

In a program, random(0, 51) is a fraction from 0 up to 51, and floor makes it whole:

number luck = floor(random(0, 51))
if (luck < 10) {
    print("unlucky:", luck)
} else {
    print("lucky:", luck)
}
lucky: 37

See Rûn Expressions and Operators.

A function

Reward(number roll) {
    if (roll >= 18) return "a ring"
    if (roll >= 10) return "a coin"
    return "nothing"
}
print(Reward(19), Reward(12), Reward(3))
a ring a coin nothing

See Rûn Functions.

Sections in a program

A program answers the same calls as an event script with on blocks:

on use {
    World.FlagSet("tour_lever_pulled")
    print("the lever moves")
}
the lever moves

See Rûn Events: Where Scripts Run.

The engine's objects

print("level", Player.level, "flag", World.Flag("tour_lever_pulled"))
level 1 flag on

See Rûn Engine Objects.

Changing a rule

before damage(number amount, text by) {
    if (by == "spark") amount = amount * 2
}

See Rûn Rule Blocks.

The console

Press the key and type a line. A call to one of the language's functions prints its value; a method call or a verb runs at once. The console does not take declarations or assignments (number n = 4, x = 5`); those belong in a program.

print(pow(2, 10))
1024