api
The one module a game needs: `local Prefix = require("prefixKit.api")`. Define prefixes (`define`, `get`, `list`, `groups`), name enemies (`nameOf`, `plural`, `rarityOf`, `setOrder`), design numbers (`stats`, `behaviours`, `describe`), put prefixes on enemies on the owner (`apply…
prefixKit.api
The one module a game needs: local Prefix = require("prefixKit.api"). Define prefixes (define, get, list, groups), name enemies (nameOf, plural, rarityOf, setOrder), design numbers (stats, behaviours, describe), put prefixes on enemies on the owner (apply, clear, of, autoApply for spawnerKit), pick nameplates (setNameplate, setNameplateRule, setNameplateOptions) and extend it (behaviour, onApplied, useSecondWind, useMedium, useSpeed, setSplitter). See the package README for every call.
Interface
What this asset declares: the schema it conforms to, what it exposes, and the rendered structured payload.
conforms to
zero/source-extract/v2nonstrict
define(id: string, def: any) → any
Add or replace a prefix: { name, group, color, look = { tint, tintBlend, emissive, scale, aura, medium, outline }, stats = { health, speed, damage, bounty (mult), armor (add) }, behaviours = { { id = "regen", pct = 0.03 }, ... }, hooks = { onSpawn, onTick, onDamaged, onDeath } }.
| arg | type | description |
|---|---|---|
| id | string | |
| def | any |
get(id: string) → any return Library
One prefix definition (nil when unknown).
| arg | type | description |
|---|---|---|
| id | string |
list(group: string?) → void
Every prefix, or the ones in one group ("rank", "size", "temper", "element", "medium").
| arg | type | description |
|---|---|---|
| group | string? |
groups( ) → void
The group names, in the order prefixes were defined.
nameOf(ids: any, baseName: string?, plural: boolean?) → string return Naming
"Watercolor Ink Goblin": prefixes in group order (setOrder), at most maxShown, then the base name; plural = true gives "Watercolor Ink Goblins".
| arg | type | description |
|---|---|---|
| ids | any | |
| baseName | string? | |
| plural | boolean? |
setOrder(groups: { string }) → void
The order groups are named in. Default { "rank", "size", "element", "temper", "medium" }.
| arg | type | description |
|---|---|---|
| groups | { string } |
setMaxShown(n: number) → void
Show at most n prefixes in a name (default 4).
| arg | type | description |
|---|---|---|
| n | number |
plural(name: string) → string return Naming
English plural of a name ("Wolf" -> "Wolves", "Armoured Knight" -> "Armoured Knights").
| arg | type | description |
|---|---|---|
| name | string |
rarityOf(ids: any, explicit: string?) → string return Naming
The rarity a prefix list reads as (normal, magic, rare, unique), or `explicit` when it is one of them.
| arg | type | description |
|---|---|---|
| ids | any | |
| explicit | string? |
rarityColor(r: string) → string return Naming
The colour of a rarity ("#e8e8e8" normal, "#6f9cff" magic, "#ffd84a" rare, "#ff9636" unique).
| arg | type | description |
|---|---|---|
| r | string |
parseKind(kind: string) → void
"goblin__watercolor_ink" -> ({ "watercolor", "ink" }, "Goblin").
| arg | type | description |
|---|---|---|
| kind | string |
stats(baseStats: any, ids: any) → any return Stats
Base stats with prefixes applied: health/speed/damage/bounty multiplied, armor added. Pure: use it to design waves and kinds.
| arg | type | description |
|---|---|---|
| baseStats | any | |
| ids | any |
behaviours(ids: any) → void
The merged behaviour list a set of prefixes gives (one entry per behaviour, params merged).
| arg | type | description |
|---|---|---|
| ids | any |
describe(ids: any) → void
One line per behaviour, in words ("heals 3% of max health per second").
| arg | type | description |
|---|---|---|
| ids | any |
apply(entity: any, ids: any, opts: any?) → string
On the OWNER: put prefixes on an enemy. Writes the synced PrefixTags component, applies stats (SecondWind health, spawnerKit speed and damage) and behaviours; every peer draws the look and nameplate. opts: { baseName, rarity, health, speed, scale }. Returns the display name.
| arg | type | description |
|---|---|---|
| entity | any | |
| ids | any | |
| opts | any? |
clear(entity: any) → void
On the owner: take every prefix off and restore the enemy's own stats.
| arg | type | description |
|---|---|---|
| entity | any |
of(target: any) → any
What an entity wears, from its synced tags (works on every peer): { prefixes, name, baseName, rarity, stats, state } or nil.
| arg | type | description |
|---|---|---|
| target | any |
speedMultiplier(target: any) → number
On the owner: the live speed multiplier of an enemy (prefixes x dash x enrage x auras x chill). For games that move their own enemies.
| arg | type | description |
|---|---|---|
| target | any |
isTargetable(target: any) → boolean
On the owner: whether an enemy may be targeted now (false while a phase behaviour hides it).
| arg | type | description |
|---|---|---|
| target | any |
setNameplate(style: string) → void
Pick the nameplate style for every plate: floating, comicCaption, brush, pixelTag, banner, neon, minimal, hidden.
| arg | type | description |
|---|---|---|
| style | string |
nameplates( ) → void
Every nameplate style: { id, name, purpose }.
nameplate( ) → string return Nameplates
The current nameplate style.
setNameplateRule(rule: string) → void
Which enemies get a plate: always, elitesOnly (2+ prefixes or rare/unique), onHover, nearCursor, bosses.
| arg | type | description |
|---|---|---|
| rule | string |
setNameplateOptions(o: any) → void
{ healthBar = true, maxVisible = 40, updateHz = 30 (how often the plate screen is rebuilt; 0 = every frame), scale = 1, colorByRarity = true, scaleWithDistance = true, declutter = true, nearCursorRadius = 220, refDistance = 32, minScale, maxScale, maxDistance = 140 }.
| arg | type | description |
|---|---|---|
| o | any |
setLookOptions(o: any) → void
Look options on this peer: { tint, outline, rarityOutline, auras, motes, maxMotes = 10, medium, scale }.
| arg | type | description |
|---|---|---|
| o | any |
onApplied(fn: any) → void
Listen for prefixes applied (on the owner): fn(entity, { prefixes, name, baseName, rarity, stats }). Returns a function that stops it.
| arg | type | description |
|---|---|---|
| fn | any |
onSlow(fn: any) → void
Be told when a chill hit lands on something that is not a prefixed enemy (a player, a tower): fn(targetId, fraction, seconds, byId).
| arg | type | description |
|---|---|---|
| fn | any |
onSpeed(fn: any) → void
Be told when an enemy's speed multiplier changes (owner): fn(entity, multiplier). For games that move their own enemies.
| arg | type | description |
|---|---|---|
| fn | any |
behaviour(id: string, impl: any) → void
Define a new behaviour: impl = { defaults, describe(p), start(ctx,p,st), tick(ctx,p,st,dt), damaged(ctx,p,st,amount,info)->amount, hit(ctx,p,st,target,amount), allyDied(ctx,p,st,ally), death(ctx,p,st), stop(ctx,p,st) }.
| arg | type | description |
|---|---|---|
| id | string | |
| impl | any |
behaviourIds( ) → void
Every behaviour id.
useSecondWind(mod: any?) → void
Use this SecondWind module (default: found by itself as "SecondWind.api").
| arg | type | description |
|---|---|---|
| mod | any? |
useMedium(mod: any?) → void
Use this mediumKit module for art-medium looks (default: found by itself; tint is the fallback).
| arg | type | description |
|---|---|---|
| mod | any? |
useSpeed(adapter: any) → void
For games with their own movers: { get = fn(entity) -> baseSpeed, set = fn(entity, speed, multiplier) }.
| arg | type | description |
|---|---|---|
| adapter | any |
setSplitter(fn: any) → void
How splitOnDeath makes copies: fn(parent, count, { prefixes, baseName, kind, scale, health }) -> { entities }. The kit applies the prefixes to what it returns. Default: creepsKit.spawnFrom, else spawnerKit's spawner.
| arg | type | description |
|---|---|---|
| fn | any |
autoApply(fn: any?) → void
spawnerKit: on the owner, every spawned enemy gets fn(enemyEntity, kind) -> (prefixIds, baseName?, opts?). With no fn, kinds named "base__a_b" wear prefixes a and b ("goblin__watercolor_ink" -> Watercolor Ink Goblin). Pass false to stop.
| arg | type | description |
|---|---|---|
| fn | any? |
debugStats( ) → any
Counters for profiling: runtime (owner), visuals and nameplates (this peer).
Sub-parts
Everything contained inside this part. Assets are composite children (clickable cards). Files are leaf payloads. Expand any row to view its source.
Showing up to 3 levels deep. Open a part to see what it holds further down.
Problems
Everything affecting this asset right now: its own problems, anything wrong inside it, and problems on its direct dependencies.
agent_score is exposed.+ quality × 0.35
+ performance × 0.25
± compat factor
Usability ratings
Did the part work as advertised when consumers tried to drop it in. Separate from upvotes: those are taste; this is "did it function".
Scoped to this part · feeds back into the world's score.