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.
Reacting to the game
Section titled “Reacting to the game”A hook runs your code when something happens. This script greets every player who logs in.
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.
Giving behaviour to an NPC
Section titled “Giving behaviour to an NPC”A node script belongs to one thing you place in Forge. Give this one to an NPC, and players can talk to it.
node<Npc>()
on_self_option("Talk-to") { _ -> self.addComponent( Speaking("Welcome to Lumbridge.") )}Adding your own code
Section titled “Adding your own code”A file can hold values and functions next to its hooks.
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.
- Guides: Riftlang for JS/TS programmers, Riftlang for Java programmers, Riftlang for Kotlin programmers and Riftlang tooling in 5 minutes.
- The language: start at Basic syntax, or look a word up in the Keyword reference.
- The game: Gameplay hooks, Lifecycle hooks, The Rift ECS and Save files and persistence.