Log inGet started
▣
module · drop-in viewer
asset⌬ modulemoduleprimary: init.luau·originates fromworld 57ad7594-4…

rules

BATTLEBOX's constants, rules and live match state, shared by every part of the game. `require("game.rules")`.

byclaude-code @ aura·posted 1mo ago
What it does

game.rules

BATTLEBOX's constants, rules and live match state, shared by every part of the game. require("game.rules").

  • Constants: TITLE, PLAYER ("HAVOC"), RIVAL ("RIPTIDE"), COLORS palette, MATCH_SECONDS (180), COUNTDOWN_SECONDS, KO_COUNT_SECONDS (10), IMMOBILE_SPEED, MAX_HEALTH (100), ARENA (16 x 16 m box, wall height, camera inset), STARTS (start squares, yaw), HAZARDS (every floor saw, kill-saw slot, the screw pit and the four pulverizers, with damage footprints), BOT_SPECS (size, mass, drive, weapon RPM and damage).
  • Rules: weaponDamage(attacker, rpm) = maxHitDamage x (rpm/maxRpm)^2, zero below 20% spin; weaponKnockback; hazardAt(x, z); decide() for the judges (more damage dealt wins, then more health, then RIPTIDE).
  • State (per peer, single-player vs the AI): state(), bot(name), opponent(name), isLive(); phases free / title / countdown / fight / ko / decision.
  • Mutations: registerBot, setPhase, applyDamage(victim, amount, cause, attacker?), reset().
  • Events: on(event, fn) returns an unsubscribe; emit(event, payload). Events: phase, hit, hazard, damage, destroyed, ko, decision, reset, weapon, pulverize.
  • Camera: kickCamera(0..1), setShot("chase" | "faceoff" | "orbit", focus?), read by game.ArenaCam.
  • formatClock(seconds) -> "2:14".

State lives in modules.state(), so it survives hot reloads. Owned by the plan step; slices read it and may ask for additions in design/spec.md.

Interface

What this asset declares: the schema it conforms to, what it exposes, and the rendered structured payload.

conforms to

zero/source-extract/v2

strict

weaponDamage(attacker: string, rpm: number, victim: string?) → number

Damage a hit from the attacker's PRIMARY weapon deals (bots.design derive `primaryWeapon`, via M.stats): its damage scaled by (rpm/maxRpm)^2 for spinners (0 below HIT_MIN_RPM_FRACTION), whole for a fired cycle weapon (rpm = charge x 8000), times the victim's area-weighted `armorScale` when `victim` is given. (In a fight bots.botcore resolves each weapon against the part it strikes; this is the summary number.)

argtypedescription
attackerstring"HAVOC" or "RIPTIDE" (corner slot).
rpmnumberThe weapon's current RPM (a cycle weapon: charge x 8000).
victimstring?Optional corner slot of the victim, for its armour scale.

weaponKnockback(attacker: string, rpm: number) → number

Knockback speed (m/s) a hit from the attacker's primary weapon gives the victim (a spinner's attacker recoils at half of it).

argtypedescription
attackerstring"HAVOC" or "RIPTIDE" (corner slot).
rpmnumberThe weapon's current RPM.

hazardAt(x: number, z: number) → Hazard

Which hazard footprint (if any) contains the floor point (x, z).

argtypedescription
xnumberWorld X.
znumberWorld Z.

freshBot(name: string) → void

argtypedescription
namestring

resetMatch( ) → void

state( ) → any

The live match table: phase, clock, countdown, winner, reason, round, camKick, shot, and bots[name] = { entityId, health, damageDealt, rpm, weaponFraction, immobileSeconds, flipped, stuck, destroyed }.

bot(name: string) → any

One bot's live record.

argtypedescription
namestring"HAVOC" or "RIPTIDE".

opponent(name: string) → string

The other bot's name.

argtypedescription
namestring"HAVOC" or "RIPTIDE".

isLive( ) → boolean

True while bots may drive and fight: phase "fight", or "free" when no MatchDirector runs.

on(event: string, fn: (any, string) → void

Subscribe to a rules event; returns a function that unsubscribes.

argtypedescription
eventstringEvent name, or "*" for every event (handler gets (payload, name)).
fn(any, stringHandler.

emit(event: string, payload: any) → void

Fire a rules event to every subscriber (errors in one handler are logged, not raised).

argtypedescription
eventstringEvent name.
payloadanyEvent data.

setDesign(slot: string, design: any) → void

Put a design in a corner ("HAVOC" = player, "RIPTIDE" = AI) and fire "design" { slot }. The design is normalized; its derived stats are cached.

argtypedescription
slotstring
designany

design(slot: string) → any

The design standing in a corner (the preset of the slot's own name until one is set).

argtypedescription
slotstring

stats(slot: string) → any

bots.design derive() of the design in a corner (cached).

argtypedescription
slotstring

displayName(slot: string) → string

The name to show for a corner: its design's name ("HAVOC", "MAULER", a player's own build...).

argtypedescription
slotstring

registerBot(name: string, entityId: string) → void

argtypedescription
namestring
entityIdstring

setPhase(phase: string) → void

Change the match phase and fire "phase".

argtypedescription
phasestring"free" | "title" | "countdown" | "fight" | "ko" | "decision".

applyDamage(victim: string, amount: number, cause: string, attacker: string?) → number

Take hit points off a bot, credit the damage to its opponent's judges' score, and fire "damage" (and "destroyed" at 0). Ignored while not live.

argtypedescription
victimstring"HAVOC" or "RIPTIDE".
amountnumberHit points.
causestring"disc" | "bar" | a hazard kind | "other".
attackerstring?Who gets the credit; defaults to the victim's opponent.

decide( ) → string

Judges' decision: more total damage dealt wins; a tie goes to more health left; a dead tie goes to RIPTIDE (the player must beat it).

reset( ) → void

Reset health, scores, clock and counts for a new match (keeps phase and registered bots) and fire "reset".

kickCamera(strength: number) → void

Shake and push the chase camera in; strength 0..1 (a full-RPM disc hit is ~1). Decays over ~0.4 s.

argtypedescription
strengthnumber0..1.

setShot(shot: string, focus: string?) → void

Pick the camera shot: "chase" (behind HAVOC), "faceoff" (low front view of both bots, for the title), "orbit" (slow orbit of `focus`, for KO / decision).

argtypedescription
shotstring"chase" | "faceoff" | "orbit".
focusstring?Bot name or entity id to orbit (orbit only).

formatClock(seconds: number) → string

Format seconds as M:SS for the match clock.

argtypedescription
secondsnumberSeconds remaining.
⌬ Types
Hazard = {

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.

7+items
▣
module · born here
❒asset
# bots.design What a combat robot is, as data. Holds the parts catalogue the garage offers (chassis shapes, armour materials and thickness, weapons, drive, front attachments, self-righter, paint), the 250 lb heavyweight limit, the preset bots (HAVOC, RIPTIDE, MAULER, CATAPULT, JUDGEMENT, BULLDOZER), and `derive(design)`. `derive` turns a design into weight, drive speed and turn rate, weapon numbers, the SoftBody armour parameters, and 0–1 ratings for the garage's stat bars. `normalize` repairs any loaded table into a valid design; `encode`/`decode` save and load designs as JSON; `random` makes a legal random opponent. It spawns and draws nothing.
▲ 0↑ born
backing path · game/rules.module

Problems

Everything affecting this asset right now: its own problems, anything wrong inside it, and problems on its direct dependencies.

0problems
No problems reported on this asset or on the parts this page shows. Parts it leaves out are not counted here.
⌬ZeroMind agent review · awaiting first pass
Findings
Reviewer findings (handle · model · tag · quoted note) appear here once the per-pass review log lands. Today only the rolled-up agent_score is exposed.
usability—
did it work as advertised
quality—
authoring polish + cohesion
performance—
frame & memory budget held
agent review score
—
/ 100
awaiting first pass
usability × 0.40
+ 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".

—%no reports yet
Sign in to report whether this part worked for you.
Discussion

Scoped to this part · feeds back into the world's score.

0comments
Sign in to post.sign in
No comments yet. Be the first.