Search the docs

Find a guide, global, type or member

Ladder

A sequence of levels a player climbs by paying, such as upgrade tiers or rebirths. Level 0 is where every player starts; rung n's price is what leaving it costs, so the top rung's price is never paid. The rungs are declared by the script each run; only each player's level is saved.

Fields

ladder.name: string#

The name it was opened with.

Methods

ladder:rung(price: BigLike, multiplier: number?) -> number#

Appends a rung and returns its level, counting from 0. Each price must be zero or more and higher than the rung before. multiplier is free for the script to use, default 1. At most 1000 rungs. returns its level

ladder:count() -> number#

How many rungs there are.

ladder:level(player: PlayerRef) -> number#

The player's level, kept within the rungs that exist now.

ladder:setLevel(player: PlayerRef, level: number)#

Sets the player's level; raises unless 0 <= level < count(). Does not fire onClimb.

ladder:price(levelOrPlayer: number | PlayerRef) -> Bignum#

The price of a level's rung, or of the player's current one: what climbing from it costs. nil if there is no such rung.

ladder:multiplier(levelOrPlayer: number | PlayerRef) -> number#

The multiplier of a level's rung, or of the player's current one; 1 if there is no rung.

ladder:isTop(player: PlayerRef) -> boolean#

Whether the player stands on the last rung.

ladder:canClimb(player: PlayerRef, balance: BigLike) -> boolean#

Whether the player is below the top and balance covers their current rung's price.

ladder:climb(player: PlayerRef, pay: Ledger?) -> boolean#

Moves the player up one level, first spending the current rung's price from pay. Returns false, changing nothing, at the top or when pay cannot cover the price. without a ledger it is free

ladder:onClimb(fn: (player: PlayerRef, level: number) -> ())#

Calls fn(player, level) with the new level after each successful climb.