cityrp.layers
Effect layering/stacking library for attributes multiple systems modify at once.
- Servercityrp.layers.Clear(ply, name, effect)Source ☍
-
Clear a named effect from a player's attribute stack, and reapply immediately.
Parameters
- plyPlayerThe player to apply the resolved value to.
- namestringAttribute name, as passed to Define.
- effectstringThe effect's name, as passed to Set.
- Servercityrp.layers.ClearAll(ply, name)Source ☍
-
Clear every effect from a player's attribute stack, and reapply immediately.
Parameters
- plyPlayerThe player to apply the resolved value to.
- namestringAttribute name, as passed to Define.
- Servercityrp.layers.Define(name, def)Source ☍
-
Register a stackable attribute. Called once by the plugin that owns it.
Parameters
- namestringAttribute name, e.g. "runspeed".
- def{ combine: fun(values: table<string, any>):(any, apply: fun(ply: Player, resolved: any, ...any)) }The attribute's combine/apply pair.
- Servercityrp.layers.Dump(ply, name)Source ☍
-
Print a player's layer stacks to the server console, for debugging live speed complaints.
Parameters
- plyPlayerThe player whose stacks to dump.
- namestring?Attribute name to dump; every populated attribute if omitted.
- Servercityrp.layers.Get(ply, name) → any, anySource ☍
-
Read a player's current resolved value for an attribute, without applying it. A player with no stack combines over no layers rather than answering nil, so callers need no fallback of their own. Unlike Set and Clear, this does not create the stack.
Parameters
- plyPlayerThe player to read the attribute off.
- namestringAttribute name, as passed to Define.
Returns
- 1anyThe combine's result, as apply would have received it.
- 2anyAny further results, for a combine that returns more than one.
- Servercityrp.layers.IsDefined(name) → booleanSource ☍
-
Check whether an attribute has been registered with Define.
Parameters
- namestringAttribute name, e.g. "runspeed".
Returns
- booleanTrue if Define has been called for this name.
- Servercityrp.layers.MULTIPLY(values) → numberSource ☍
-
Combine helper: multiplies every layer's value together.
Parameters
- valuestable<string, number>The active effects' contributions, keyed by effect name.
Returns
- numberThe product of every value in the table.
- Servercityrp.layers.New(name) → LAYER_STACKSource ☍
-
Construct a new layer stack for a registered attribute.
Parameters
- namestringAttribute name, as passed to Define.
Returns
- LAYER_STACKThe newly created stack, bound to the attribute's combine/apply.
- Servercityrp.layers.Reapply(ply, name)Source ☍
-
Reapply a player's resolved value for an attribute even if it hasn't changed. Does nothing, and creates no stack, for a player with no stack for it.
Parameters
- plyPlayerThe player to apply the resolved value to.
- namestringAttribute name, as passed to Define.
- Servercityrp.layers.Set(ply, name, effect, value)Source ☍
-
Set a named effect's value on a player's attribute stack, and reapply immediately.
Parameters
- plyPlayerThe player to apply the resolved value to.
- namestringAttribute name, as passed to Define.
- effectstringThe effect's name, used as its key on the stack.
- valueanyThe effect's contribution, combined with any others already on the stack.
- Servercityrp.layers.SUM(values) → numberSource ☍
-
Combine helper: sums every layer's value together.
Parameters
- valuestable<string, number>The active effects' contributions, keyed by effect name.
Returns
- numberThe sum of every value in the table.
- Servercityrp.layers.LAYER_STACKSource ☍
-
Per-player, per-attribute stack of named modifiers, recombined and applied on every change.
- Servercityrp.layersSource ☍
-
Registry of attributes that can be stacked, and the per-player stacks built from them. See: LAYER_STACK
Per-player, per-attribute stack of named modifiers, recombined and applied on every change.
- ServerLAYER_STACK.applySource ☍
-
Turns the resolved value (and any extra data from combine) into a real
Set*call. Empty for an attribute nothing pushes, read withGetinstead. - ServerLAYER_STACK.combineSource ☍
-
Reduces the full layer table to a resolved value, plus any extra data apply needs (e.g. for overriding).
- ServerLAYER_STACK.layersSource ☍
-
Current modifiers, keyed by effect name.
- ServerLAYER_STACK.resolvedSource ☍
-
The combine results last passed to apply, used to skip redundant applies.