api
The contract other kits use with slash2D: `Slash.addTarget(entityId, { halfW, halfH, offsetX?, offsetY?, onHit })` / `Slash.removeTarget(handle)` to make an entity hittable on this peer, `Slash.on("swing" | "hit", fn)` for events every peer gets, and `Slash.schemeWithAttack(baseN…
api
The contract other kits use with slash2D: Slash.addTarget(entityId, { halfW, halfH, offsetX?, offsetY?, onHit }) / Slash.removeTarget(handle) to make an entity hittable on this peer, Slash.on("swing" | "hit", fn) for events every peer gets, and Slash.schemeWithAttack(baseName) to build a controlsKit scheme with an attack button. Called by enemy and prop code and by the Slash2D component.
Interface
What this asset declares: the schema it conforms to, what it exposes, and the rendered structured payload.
conforms to
zero/source-extract/v2strict
addTarget(entityId: string, opts: TargetOpts) → number
Make an entity hittable on this peer: a box `halfW` x `halfH` (tiles) around its position plus (offsetX, offsetY). When the thing is drawn somewhere other than its entity (a boss whose sprite moves while its entity stays put), pass `box()` returning its live { x, y, halfW, halfH } (centre, tiles), or nil when it cannot be hit right now; it is asked at every swing. `onHit(hit)` runs on the attacker's peer; return false to refuse the hit (nil or true counts it). Returns a handle for removeTarget.
| arg | type | description |
|---|---|---|
| entityId | string | |
| opts | TargetOpts |
removeTarget(handle: number) → void
Stop an entity being hittable (the handle addTarget returned). Unknown handles are ignored.
| arg | type | description |
|---|---|---|
| handle | number |
targets( ) → void
Every target registered on this peer, pruned of entities that no longer exist.
targetBox(t: Target) → Box
Where a target can be hit right now: its `box()` when it has one, else its entity's current position plus the offsets. Nil when its box says it cannot be hit or its entity is gone.
| arg | type | description |
|---|---|---|
| t | Target |
isTarget(entityId: string) → boolean
Is this entity registered as a target on this peer?
| arg | type | description |
|---|---|---|
| entityId | string |
on(name: string, fn: (any) → void
Listen on this peer: "swing" fires for every swing any player makes ({ player, dir, dirX, dirY, x, y, isLocal }); "hit" fires on every peer for every counted hit ({ player, target, damage, dir, dirX, dirY, x, y, isLocal, pogo }). "*" hears both. Returns a connection with :Disconnect().
| arg | type | description |
|---|---|---|
| name | string | |
| fn | (any |
off( ) → void
emit(name: string, payload: { [string]: any }) → void
Fire an event on this peer (Slash2D does this). Returns the payload.
| arg | type | description |
|---|---|---|
| name | string | |
| payload | { [string]: any } |
schemeWithAttack(baseName: string) → any
A fresh copy of controlsKit scheme `baseName` with an `attack` action added (keys X / H / left mouse, pad right trigger or left shoulder, a touch button). Extend it and register it with controlsKit.schemes.register.
| arg | type | description |
|---|---|---|
| baseName | string |
registerScheme( ) → string
Register the `platformerSlash` scheme (platformer + attack) so `controlsKit` can use it; the Slash2D component does this itself. Returns the scheme name.
attackDown( ) → boolean
Are the attack's default buttons (X, H, left mouse; the pad's right trigger or left shoulder) held right now, read straight from the engine's input? Slash2D falls back to this when the live controlsKit scheme in the build it reads has no `attack` action, so the sword always swings.
useScheme(name: string, scheme: any?) → boolean
For a game that gives the player a scheme of its own (one with an `attack` action): register `scheme` (when given) in the controlsKit build slash2D reads and switch that build to `name`, so the attack button reads there too. A world can hold several controlsKit builds side by side, and a scheme registered in one is unknown to the others. Cheap when `name` is already in use; returns true when it is.
| arg | type | description |
|---|---|---|
| name | string | |
| scheme | any? |
overlaps(ax: number, ay: number, ahw: number, ahh: number, bx: number, by: number, bhw: number, bhh: number) → boolean
Overlap of two boxes given as centre and half extents.
| arg | type | description |
|---|---|---|
| ax | number | |
| ay | number | |
| ahw | number | |
| ahh | number | |
| bx | number | |
| by | number | |
| bhw | number | |
| bhh | number |
Hit = { damage: number, dirX: number, dirY: number, attacker: string, x: number, y: number }Box = { x: number, y: number, halfW: number, halfH: number }TargetOpts = {Target = { handle: number, id: string, halfW: number, halfH: number, offsetX: number, offsetY: number, onHit: (hit: Hit) -> boolean?, box: (() -> Box?)? }Connection = { Disconnect: (any) -> (), disconnect: (any) -> () }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.