Skip to content
You're reading the docs for Railroader 0.6 (the MoW Update), currently available on the Experimental branch.

Globals

These are always available in every script — no import required. Internally they’re registered as separate native modules (core, vector3, coroutine), but that boundary isn’t visible to scripts and isn’t worth remembering: just use them.

FunctionDescription
print(value)Log a value at info level
length(value)Length of a string, array, or dictionary
isEmpty(value)true for null, an empty string, array, or dictionary
assert(condition, message?)Throw if condition is false
time()Seconds since the game started (scaled)
realtimeSinceStartup()Seconds since the game started (unscaled)
deltaTime()Time since the last frame
frameCount()Current frame number
startsWith(str, prefix) / endsWith(str, suffix) / contains(str, substring)String search
toLowerCase(str) / toUpperCase(str)Case conversion
trim(str)Remove leading/trailing whitespace
replace(str, oldValue, newValue)Replace all occurrences
substring(str, startIndex, length)Extract a substring
pcall(func, ...args)Call func in a protected context; returns [true, result] or [false, errorMessage] instead of throwing
getSourceLocation(frameIndex)Debug: source location string for a call-stack frame

A value-semantics 3D vector type.

var a = Vector3(1, 2, 3)
var b = Vector3.up
var d = a.distance(b)
ConstructorDescription
Vector3()(0, 0, 0)
Vector3(s)(s, s, s)
Vector3(x, y, z)Explicit components
PropertyTypeDescription
x / y / zfloatComponents (read/write)
magnitudefloatLength (read-only)
sqrMagnitudefloatSquared length (read-only)
normalizedVector3Unit-length copy (read-only)
MethodDescription
normalize()Returns a unit-length copy
dot(other)Dot product
cross(other)Cross product
distance(other)Distance to another vector
lerp(other, t)Linear interpolation toward other
slerp(other, t)Spherical interpolation toward other
scale(other)Component-wise multiply
MemberDescription
Vector3.zero / .one(0,0,0) / (1,1,1)
Vector3.up / .down / .left / .right / .forward / .backUnit direction vectors
Vector3.dot(a, b) / .cross(a, b) / .distance(a, b) / .angle(a, b)Static equivalents

Schedules a closure to run cooperatively over multiple frames, where coroutines are supported by the host context. Distinct from the language’s built-in yield-based generators: Coroutine() is a native function that hands a closure to the host’s coroutine manager, rather than a language construct.

var handle = Coroutine(() => {
yield null // suspend one frame
print("resumed")
})
if handle.isRunning {
handle.stop()
}

Starts closure as a coroutine and returns a CoroutineHandle.

MemberTypeDescription
isRunningboolWhether the coroutine is currently running
isDoneboolWhether the coroutine has finished
isStoppedboolWhether the coroutine was stopped before completion
errorstring?Error message if the coroutine threw, else null
namestringCoroutine name (for debugging)
stop()—Stop the coroutine