Vǫrðr Forge Steam page

Rûn Language

Rûn Language

Rûn is the scripting language of Vordr. Everything a game does beyond walking, talking and fighting on its own is a Rûn script: a door that opens, a counter that remembers, a random reward, a boss that changes its mind at half health, a rule that changes how much a hit hurts.

This section is the language's manual. It is written for a maker who has built games with events in Construct 2, GameMaker or RPG Maker and knows a little scripting. It describes what the engine does today. Every example in it has been run in the engine on a new project, or, where it needs something a new project does not have (a villager, a zone, a fight), read by the engine's checker; where an example prints something, the output shown is what the engine printed.

Two kinds of script

Rûn has two kinds of script that a maker writes every day. They share the .run file ending and live in two folders.

Event scripts
assets/events/<name>.run. Sections in square brackets ([use], [enter]), one verb per line: say, give, set, if, wait. The world calls a section by name. Their variables are shared by every event script and kept in the save. They can wait. See Line Scripts and Rûn Verb Index.
Programs
assets/scripts/<name>.run. Braces, typed variables, functions, if, while, for, and the engine's objects (Player, World, Camera). They answer the same calls with on use { } blocks, and they alone can change the engine's own events as they happen (before damage). They run to the end at once; they cannot wait. See Rûn Programs.

A third kind, the block script (Block Scripts), lives in assets/events too and is written with braces: Begin Event "ambush" on enter { ... }. It is made for scenes where several things happen at once. It is covered with cutscenes in Rûn Events: Where Scripts Run.

Which one to reach for

A reaction in the world (a door, a sign, a zone)
An event script.
A number that must still be there after a save
An event script's variable (set, add).
A pause between two things
An event script (wait 2), or a block script (Wait 2s).
Arithmetic, loops, a function you call from several places
A program.
Changing what the engine is about to do (damage, a roll, a pickup)
A program's before block. See Rûn Rule Blocks.
Something every frame
A program with on update(number dt).
A scene with the camera and people moving at once
A block script.

The two kinds work together. A program runs any script's section with World.Fire("<name>", "<section>"), and a program named like an event answers that event in place of the event script. An event script's run reaches a program too, when no event script has that name.

If you know Construct 2 or GameMaker

An event sheet's event
A section of an event script: [use], [enter]. The thing that calls it is the condition that starts it.
A global variable
An event script variable: set coins 0, add coins 5.
An instance variable
A custom property on a prop, read with prop(<prop>, <key>); or a field of a program's object.
Every tick
A program's on update(number dt), or an event section with every 0.25.
Wait
wait 1.5 in an event script.
random(50)
rand or random? Both work, in a program and in an event script. random(50) is any number from 0 up to 50, fractions included, as in Construct. rand(50) is a whole number from 0 to 49, and rand(1, 6) a whole number from 1 to 6.
round(random(0, 50))
round(random(0, 50)) works in a program; floor(random(0, 51)) gives every whole number from 0 to 50 the same chance.
Trigger once
A flag: require flag <name> : <section>, then flag set <name>.
A function
A program's function, or an event section you run.

How this manual is laid out

  1. Rûn Quick Tour: the whole language on one page.
  2. Rûn Tutorial: The Wishing Well: one small thing built step by step.
  3. The reference, by topic: Rûn Lexical Structure, Rûn Values and Types, Rûn Variables and Scope, Rûn Expressions and Operators, Rûn Statements and Control Flow, Rûn Functions, Rûn Events: Where Scripts Run, Rûn Engine Objects, Rûn Rule Blocks, Rûn Saving State, Rûn Errors and the Checker, Rûn Performance.
  4. The cookbook: Rûn Cookbook: Logic and Rûn Cookbook: The World.
  5. Rûn Glossary and the Rûn Style Guide.

The lists of every verb and every engine method are on Rûn Verb Index and Rûn Programs; this manual links to them rather than copying them.

In the examples, a second block straight after a program or a console line is what it printed; a second block after an event script is the line the player saw at the bottom of the screen. Where the numbers change from run to run (a random roll), the block shows one run's numbers.

Trying a line

The Rûn Console (the ` key, or Tools > Rûn Console) runs a line the moment you press Enter. A call to one of the language's own functions prints its value:

round(random(0, 50))
print("two and two make", 2 + 2)
37
two and two make 4