Skip to content

rift.scripting

fun Entity.board(
projection: WorldProjection,
at: Tile3? = null
)
Example
node<WorldProjection>()
on_self_option("Board") { clicker ->
clicker.board(self)
clicker.message("You climb aboard. Any teleport takes you off again.")
}
fun broadcast(text: String)
Example
on_input<DeveloperCommandInput> { player ->
if (name == "restart") broadcast("The realm will restart in 5 minutes.")
}
fun Entity.clearHintArrow()
Example
on_login { player -> player.hintArrow(Tile4.global(3222, 3218), height = 100) }
on_world_click { player -> player.clearHintArrow() }
fun Entity.flag(at: Tile4)
Example
on_new_account { player ->
player.flag(Tile4.global(3208, 3220, height = 2))
player.message("Head for the flag to find the bank.")
}
fun Entity.hintArrow(
at: Tile4,
height: Int = 0
)
Example
on_new_account { player ->
val hans = World.spawn(Assets.Npc.hans, player.tile4)
player.hintArrow(hans.tile4)
player.message("Talk to Hans to begin.")
}
fun Entity.isIn(scene: Scene): Boolean
Example
on_login { player ->
if (player.isIn(Scenes.boss_arena)) player.message("You wake up in the arena.")
}
fun Entity.kick(reason: String)
Example
on_login { player ->
if (!player.inGroup("tester")) player.kick("This realm is open to testers only.")
}
fun Entity.message(text: String)
fun Entity.message(
text: String,
kind: ChatMessageType
)
Example
on_object_option(Assets.WorldObject.poordoor, "Open") { player ->
player.message("The door is locked.")
player.message("Someone has scratched 'go away' into it.", ChatMessageType.ExamineObject)
}
fun Entity.playSound(
sound: SoundEffectDefinition,
loops: Int = 1,
delay: Int = 0
)
Example
fun ringBell(player: Actor, bell: SoundEffectDefinition) {
player.playSound(bell, loops = 3)
player.message("Ding, ding, ding.")
}
fun WorldItem.remove()
Example
on_world_item_option(Assets.Item.bones, "Take") { player ->
target.remove()
player.message("You pick up the bones.")
}
fun WorldObject.replaceWith(
obj: WorldObjectDefinition,
revertAfter: Int? = null
)
Example
on_object_option(Assets.WorldObject.poordoor, "Open") { player ->
target.replaceWith(Assets.WorldObject.poordoor, revertAfter = 50)
player.message("The door swings open.")
}
fun World.respawning(
delay: Int,
create: (group: RespawnGroup) -> Unit
): RespawnGroup
Example
on_world_start {
val camp = Tile4.global(3240, 3220)
World.respawning(delay = 100) { group ->
group.add(World.spawn(Assets.Npc.goblin, camp))
group.add(World.spawn(Assets.Item.bones, camp))
}
}
fun Entity.save()
Example
on_world_item_option(Assets.Item.shark, "Take") { player ->
target.remove()
player.message("You take the golden shark!")
player.save()
}
fun Entity.showHitsplat(
name: String,
amount: Int,
source: Actor? = null
)
Example
on_npc_option(Assets.Npc.goblin.id, "Kick") { player ->
target.showHitsplat("damage", 2, source = player as? Actor)
target.speak("Ow!")
}
fun World.spawn(
npc: NpcDefinition,
at: Tile4,
facing: Direction? = null,
owner: Entity? = null
): Npc
fun NpcDefinition.spawn(
at: Tile4,
facing: Direction? = null,
owner: Entity? = null
): Npc
fun World.spawn(
obj: WorldObjectDefinition,
at: Tile4,
shape: WorldObjectShape = WorldObjectShape.CENTREPIECE_STRAIGHT,
rotation: Int = 0
): WorldObject
fun WorldObjectDefinition.spawn(
at: Tile4,
shape: WorldObjectShape = WorldObjectShape.CENTREPIECE_STRAIGHT,
rotation: Int = 0
): WorldObject
fun World.spawn(
item: ItemDefinition,
at: Tile4,
amount: Int = 1,
owner: Entity? = null
): WorldItem
fun ItemDefinition.spawn(
at: Tile4,
amount: Int = 1,
owner: Entity? = null
): WorldItem
fun World.spawn(
stack: Item,
at: Tile4,
owner: Entity? = null
): WorldItem?
fun World.spawn(
graphic: GraphicDefinition,
at: Tile4,
height: Int = 0,
delay: Int = 0
): WorldGraphic
fun GraphicDefinition.spawn(
at: Tile4,
height: Int = 0,
delay: Int = 0
): WorldGraphic
fun World.spawn(
sound: SoundEffectDefinition,
at: Tile4,
radius: Int = 5,
loops: Int = 1,
delay: Int = 0
): WorldSound
fun SoundEffectDefinition.spawn(
at: Tile4,
radius: Int = 5,
loops: Int = 1,
delay: Int = 0
): WorldSound
Example
on_world_start {
val goblin = World.spawn(Assets.Npc.goblin, Tile4.global(3240, 3220), facing = Direction.South)
World.spawn(Assets.Item.bones, Tile4.global(3241, 3220), amount = 2)
Assets.WorldObject.poordoor.spawn(Tile4.global(3238, 3220))
goblin.speak("Grr!")
}
fun Entity.speak(
text: String,
colour: ChatColour = ChatColour.None,
effect: ChatEffect = ChatEffect.None
)
Example
on_npc_option(Assets.Npc.hans.id, "Talk-to") { player ->
target.speak("Welcome to the realm!")
player.speak("Thanks, Hans.", colour = ChatColour.Cyan, effect = ChatEffect.Wave)
}
fun Entity.teleport(to: Tile4)
fun Entity.teleport(to: Tile3): Unit
fun Entity.teleport(to: Point): Unit
Example
on_input<DeveloperCommandInput> { player ->
when (name) {
"arena" -> player.teleport(Scenes.boss_arena.createShard().tile(8, 3))
"home" -> player.teleport(Tile4.global(3222, 3218))
}
}
val Entity.camera: Camera
Example
on_npc_option(Assets.Npc.hans.id, "Talk-to") { player ->
player.camera.lookAt(target.tile4, height = 200, speed = 4)
player.camera.moveTo(player.tile4, height = 600, speed = 4)
}
on_world_click { player -> player.camera.reset() }
val Entity.currentShard: Shard?
Example
on_self_option("Climb-up") { clicker ->
val home = Tile4.global(3222, 3218)
clicker.currentShard?.destroy(sendTo = home) ?: clicker.teleport(home)
}
val Entity.tile4: Tile4
Example
on_input<DeveloperCommandInput> { player ->
if (name != "where") return@on_input
val at = player.tile4
player.message("You are at ${at.tile.x}, ${at.tile.z}, plane ${at.tile.height}, shard ${at.shard}.")
}