Skip to content

Getting started with Riftlang

Riftlang is the scripting language for Rift games, and it comes with everything you need. You use it to give behaviour to things in your game, like an NPC or a door, and to react when something happens, like a player logging in. Scripts are .rift files that run on the game server. You can write them in Forge’s script editor or in your own editor.

A hook runs your code when something happens. This script greets every player who logs in.

scripts/welcome.rift
on_login { player ->
player.message("Welcome to the realm.")
}

That’s the whole script. Common Rift names like on_login are already there, with nothing to import.

A node script belongs to one thing you place in Forge. Give this one to an NPC, and players can talk to it.

scripts/lumbridge/hans.rift
node<Npc>()
on_self_option("Talk-to") { _ ->
self.addComponent(
Speaking("Welcome to Lumbridge.")
)
}

A file can hold values and functions next to its hooks.

scripts/chat/dice.rift
fun roll(sides: Int) = (1..sides).random()
on_public_chat { subject ->
if (text == "!roll") subject.message("You rolled ${roll(100)}.")
}

To use the same code in more than one file, mark it public and keep your hooks in separate scripts. See Sharing code between files.

You can also use Java jars and the JDK from Riftlang. See Riftlang for Java programmers.