rift.scripting
Functions
Section titled “Functions”fun Entity.board( projection: WorldProjection, at: Tile3? = null)node<WorldProjection>()
on_self_option("Board") { clicker -> clicker.board(self) clicker.message("You climb aboard. Any teleport takes you off again.")}broadcast
Section titled “broadcast”fun broadcast(text: String)on_input<DeveloperCommandInput> { player -> if (name == "restart") broadcast("The realm will restart in 5 minutes.")}clearHintArrow
Section titled “clearHintArrow”fun Entity.clearHintArrow()on_login { player -> player.hintArrow(Tile4.global(3222, 3218), height = 100) }
on_world_click { player -> player.clearHintArrow() }fun Entity.flag(at: Tile4)on_new_account { player -> player.flag(Tile4.global(3208, 3220, height = 2)) player.message("Head for the flag to find the bank.")}hintArrow
Section titled “hintArrow”fun Entity.hintArrow( at: Tile4, height: Int = 0)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): Booleanon_login { player -> if (player.isIn(Scenes.boss_arena)) player.message("You wake up in the arena.")}fun Entity.kick(reason: String)on_login { player -> if (!player.inGroup("tester")) player.kick("This realm is open to testers only.")}message
Section titled “message”fun Entity.message(text: String)
fun Entity.message( text: String, kind: ChatMessageType)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)}playSound
Section titled “playSound”fun Entity.playSound( sound: SoundEffectDefinition, loops: Int = 1, delay: Int = 0)fun ringBell(player: Actor, bell: SoundEffectDefinition) { player.playSound(bell, loops = 3) player.message("Ding, ding, ding.")}remove
Section titled “remove”fun WorldItem.remove()on_world_item_option(Assets.Item.bones, "Take") { player -> target.remove() player.message("You pick up the bones.")}replaceWith
Section titled “replaceWith”fun WorldObject.replaceWith( obj: WorldObjectDefinition, revertAfter: Int? = null)on_object_option(Assets.WorldObject.poordoor, "Open") { player -> target.replaceWith(Assets.WorldObject.poordoor, revertAfter = 50) player.message("The door swings open.")}respawning
Section titled “respawning”fun World.respawning( delay: Int, create: (group: RespawnGroup) -> Unit): RespawnGroupon_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()on_world_item_option(Assets.Item.shark, "Take") { player -> target.remove() player.message("You take the golden shark!") player.save()}showHitsplat
Section titled “showHitsplat”fun Entity.showHitsplat( name: String, amount: Int, source: Actor? = null)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): WorldSoundon_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)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)}teleport
Section titled “teleport”fun Entity.teleport(to: Tile4)fun Entity.teleport(to: Tile3): Unitfun Entity.teleport(to: Point): Uniton_input<DeveloperCommandInput> { player -> when (name) { "arena" -> player.teleport(Scenes.boss_arena.createShard().tile(8, 3)) "home" -> player.teleport(Tile4.global(3222, 3218)) }}Properties
Section titled “Properties”camera
Section titled “camera”val Entity.camera: Cameraon_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() }currentShard
Section titled “currentShard”val Entity.currentShard: Shard?on_self_option("Climb-up") { clicker -> val home = Tile4.global(3222, 3218) clicker.currentShard?.destroy(sendTo = home) ?: clicker.teleport(home)}val Entity.tile4: Tile4on_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}.")}