Vǫrðr Forge Steam page

Rûn Language

Rûn Performance

Rûn runs inside the game's frame. A script that does a little often, or a lot once, is fine; a script that does a lot every frame is what slows a game down. This page gives the limits the engine holds a script to and the habits that keep a game smooth.

How each kind runs

Event scripts
Read when called and run line by line. A wait hands the frame back; nothing else does until the section ends.
Programs
The whole file is read and parsed every time one of its sections or rule blocks runs, then the section runs to its end within the frame. A small file is cheap to read; a long file answering an event that fires often is not.
Live programs
A program with on update(number dt) is read once per play (again when its file changes) and keeps its variables. Its update block runs every frame, so keep it short.
Rule blocks
An engine event with no before or after block anywhere costs nothing. With blocks, every program that holds one for that event is run each time the event happens.

The limits

Lines in one event section
64; a loop may run them many times.
Event scripts running one another (run)
16 deep.
Lines one event script runs in one frame
20000; past that the script is stopped.
Event script variables
64 in a game; names up to 23 characters; text up to 63 characters.
Sections on a heartbeat (every)
16 at once, 0.25 seconds apart at the shortest.
Block scripts running at once
8.
A program file
64 KB of text, 8192 words and symbols, 1024 statements, 2048 expressions, 32 sections, 64 functions and rule blocks.
Program variables alive at once
512.
Function calls nested
16.
Laps of one while or for
100000.
Arguments of one call, parameters of one function, values in one written list
8.
List values made in one run
2048.
Objects made in one run
256.
Programs running inside one another (a rule block raised by a program, World.Fire)
8.
Live programs
8.
Text in a program
159 bytes.

A program that goes past one of these stops with an error that names it; the rest of the game goes on.

Habits

  • Answer an event rather than watching for it. A zone's [enter] costs nothing until she walks in; an on update that checks her position every frame costs every frame.
  • Prefer every 1 to every 0.25 when a second is soon enough.
  • Keep on update blocks small; move work that does not have to happen every frame into a function you call when it is needed.
  • Keep a program that answers a frequent event (before damage, before move) in a file of its own, so the file read each time is short.
  • A loop over the enemies (World.EnemyCount()) is fine in an event; in on update it runs every frame.