Skip to content

K.Currency ​

Functions ​

K.Currency.Define ​

lua
K.Currency.Define(name: string, options: { Default: number?, Min: number?, Max: number?, Saved: boolean?, Integer: boolean? }?)

Creates a currency. Names use letters, numbers and _ and start with a letter.

K.Currency.Exists ​

lua
K.Currency.Exists(name: string): boolean

K.Currency.Names ​

lua
K.Currency.Names(): { string }

K.Currency.Add ​

lua
K.Currency.Add(player: Player, name: string, amount: number, source: string?): (boolean, number)

Server: Add(player, name, amount). Returns (succeeded, newValue).

K.Currency.Take ​

lua
K.Currency.Take(player: Player, name: string, amount: number, source: string?): (boolean, number)

Server: Take(player, name, amount). Fails (and changes nothing) if they can't afford it.

K.Currency.Set ​

lua
K.Currency.Set(player: Player, name: string, value: number, source: string?): (boolean, number)

Server: Set(player, name, value). The value is kept between Min and Max.

K.Currency.Get ​

lua
K.Currency.Get(...: any): number

Server: Get(player, name). Client: Get(name) for yourself, or Get(otherPlayer, name).

K.Currency.Has ​

lua
K.Currency.Has(player: Player, name: string, amount: number): boolean

Server: Has(player, name, amount) is true when they can afford amount.

K.Currency.OnChanged ​

lua
K.Currency.OnChanged(name: string, callback: (...any) -> ())

Server: callback(player, new, old). Client: callback(new, old) for the local player.

K.Currency.Before ​

lua
K.Currency.Before(operation: string, callback: (Context) -> (), priority: number?): () -> ()

Runs before an operation on any currency. Change ctx.Amount, or ctx:Cancel("reason") to stop it.

K.Currency.After ​

lua
K.Currency.After(operation: string, callback: (Context) -> ()): () -> ()

Runs after an operation succeeded; ctx.Old and ctx.New hold the values.

K.Currency.Use ​

lua
K.Currency.Use(operation: string, callback: (Context, () -> ()) -> (), priority: number?): () -> ()

Full middleware: callback(ctx, next). Call next() to continue, or don't to stop.

K.Currency.Multiplier ​

lua
K.Currency.Multiplier(player: Player, name: string): number

The product of every multiplier source for this player and currency.

K.Currency.AddMultiplier ​

lua
K.Currency.AddMultiplier(source: (Player, string) -> number): () -> ()

Adds a source of multipliers (game passes, global events...): source(player, currency) -> factor. Every source is multiplied together when currency is added. Returns a function that removes it.

K.Currency.Override ​

lua
K.Currency.Override(operation: string, callback: (Context) -> boolean?)

Replaces an operation's core. Call ctx:Commit(value) to apply, or return false to fail.

Generated from src/Corode/Currency.luau.

Corode 0.13.0 · MIT License