Skip to main content
The Ball class represents the player-controlled ball entity in a RollingQuest level. You receive a Ball instance as the self parameter in ball-specific hooks such as OnUpdate, OnLand, and OnJump. Through it you can read the ball’s current state, change movement behaviour, manage linked balls, apply status effects, and kill the ball with a custom cause.

Identity

PropertyTypeRead-onlyDescription
typeEntityTypeAlways EntityType.Ball (5).
namestringThe unique identifier assigned to this ball.
tagstringThe tag associated with the ball, used for grouping or lookup.
skinintegerThe skin ID currently applied to the ball.

Transform

PropertyTypeRead-onlyDescription
positionVector3World-space position of the ball.
rotationQuaternionWorld-space rotation of the ball.
basisBasisThe current orientation basis of the ball.

State

PropertyTypeRead-onlyDescription
blockSlotBlockSlotThe grid slot the ball currently occupies.
sectionstringID of the level section the ball is in.
isAlivebooleantrue while the ball is alive and active.
currentMoveEntityMoveTypeThe movement action the ball is currently executing.
currentGroundSideSideThe side the ball is resting on; nil when airborne.
isOnAirbooleantrue when the ball is not touching the ground.
jumpModeBallJumpModeCurrent jump capability: Banned (0), Normal (1), or Bouncing (2).
slowModebooleanRead or write to enable/disable slow-motion movement.
mirrorModebooleanRead or write to enable/disable mirrored controls.
isBurningbooleantrue when a burning effect is active.
burningAmountnumberAccumulated burning intensity on the ball.
isIcybooleantrue when the ball has the icy status.
hasShieldbooleantrue while a shield is protecting the ball.
respawnSideSideThe side set as the ball’s current respawn point.
respawnOrientationOrientationThe orientation at the current respawn point.
propertiesElementPropertyPoolCustom property pool attached to the ball.
localDataRawLocalDataPer-instance local data store for this ball.

Methods

kill

Kills the ball after a delay. Three overloads are available:
--- @param cause LostLevelCause
--- @param timeToDie number
function Ball:kill(cause, timeToDie)

--- @param cause string
--- @param timeToDie number
function Ball:kill(cause, timeToDie)

--- @param cause string
--- @param causeIcon LostLevelCause
--- @param timeToDie number
function Ball:kill(cause, causeIcon, timeToDie)

instaKill

Kills the ball immediately without a delay. Three overloads mirror kill:
--- @param cause LostLevelCause
function Ball:instaKill(cause)

--- @param cause string
function Ball:instaKill(cause)

--- @param cause string
--- @param causeIcon LostLevelCause
function Ball:instaKill(cause, causeIcon)

teleportToSide

--- @param side Side
--- @param orientation Orientation
--- @return boolean
function Ball:teleportToSide(side, orientation)
Teleports the ball to the given side and facing orientation. Returns true on success.

doMove

--- @param move EntityMoveType
function Ball:doMove(move)
Forces the ball to perform a specific movement action.

increaseJumpMode / decreaseJumpMode

function Ball:increaseJumpMode()
function Ball:decreaseJumpMode()
Step the ball’s jumpMode up or down through Banned → Normal → Bouncing.

increaseJumpAheadDistance / decreaseJumpAheadDistance

function Ball:increaseJumpAheadDistance()
function Ball:decreaseJumpAheadDistance()
Adjust how far ahead the ball travels on a jump.

increaseJumpUpDistance / decreaseJumpUpDistance

function Ball:increaseJumpUpDistance()
function Ball:decreaseJumpUpDistance()
Adjust the vertical height of the ball’s jump.

changeGravity

--- @param newFace Face
--- @return boolean
function Ball:changeGravity(newFace)
Redirects gravity to the specified face of the current block. Returns true when the change succeeds.

enableShield / increaseShieldTime

--- @param seconds number
function Ball:enableShield(seconds)

--- @param seconds number
function Ball:increaseShieldTime(seconds)
Grant or extend the ball’s protective shield by seconds.

addBurningAmount

--- @param amount number
function Ball:addBurningAmount(amount)
Adds to the ball’s current burning accumulator.

linkBall / unlinkBall / unlinkAllBalls

--- @param ball Ball
function Ball:linkBall(ball)

--- @param ball Ball
function Ball:unlinkBall(ball)

function Ball:unlinkAllBalls()
Manage cooperative links between balls. Linked balls share certain movement events.

isBallLinked

--- @param ball Ball
--- @return boolean
function Ball:isBallLinked(ball)
Returns true when this ball is linked to ball.

getLinkedBalls / getLinkedBallsIterator

--- @return Ball[]
function Ball:getLinkedBalls()

--- @return Ball[]
function Ball:getLinkedBallsIterator()
getLinkedBalls returns a table; getLinkedBallsIterator returns an iterator-compatible form for use in for loops.

setRespawnLocation

Two overloads let you pin the respawn point to a side or to a specific block slot + face:
--- @param side Side
--- @param orientation Orientation
function Ball:setRespawnLocation(side, orientation)

--- @param slot BlockSlot
--- @param face Face
--- @param orientation Orientation
function Ball:setRespawnLocation(slot, face, orientation)

collectItem

--- @param item Item
function Ball:collectItem(item)
Forces the ball to collect the specified item immediately.

Type-cast helpers

Every entity exposes a set of as* methods. Call them when you hold a generic entity reference and need to narrow its type. Each throws an error if the cast is invalid.
function Ball:asLevel()      -- returns Level
function Ball:asBlock()      -- returns Block
function Ball:asSide()       -- returns Side
function Ball:asItem()       -- returns Item
function Ball:asEnemy()      -- returns Enemy
function Ball:asBall()       -- returns Ball
function Ball:asDecoration() -- returns Decoration

BallData

BallData is the raw, mutable representation of a ball used when building or modifying level data (e.g. in OnLevelLoad). It holds the initial spawn position, scripting fields, and design-time properties.
PropertyTypeRead-onlyDescription
initialPositionBlockLocationThe block location where the ball spawns at level start.
templatestringTemplate identifier that determines the ball’s appearance and base behaviour.
scriptRefstringScript file reference attached to this ball.
scriptTagstringTag forwarded to the ball’s script.
scriptVarsScriptVariablesVariable table passed into the ball’s script.
propertiesElementPropertiesDataDesign-time property data for the ball.
Call clear() to reset a BallData instance to empty defaults.

Usage Example

The following OnUpdate hook reads the ball’s position every frame and kills it instantly when it falls below y = –20:
function OnUpdate(self, deltaTime)
    -- self is a Ball
    local pos = self.position

    if pos.y < -20 then
        self:instaKill("Fell into the void")
    end

    -- Slow the ball down when it enters a particular section
    if self.section == "danger_zone" then
        self.slowMode = true
    else
        self.slowMode = false
    end
end