assembler.module
README.md
bots.assembler
Builds the look of any v2 bots.design design out of runtime procedural meshes. No assets are written. Every part becomes its own entity under the bot's Visual, drawn as its type's shape from bots.parts.
local Assembler = require("bots.assembler")
local h = Assembler.build(rootEntity, design) -- replaces root's "Visual" child
Assembler.updatePart(h, part) -- one part changed (the editor calls this every drag frame)
Assembler.addPart(h, part); Assembler.removePart(h, id)
Assembler.refreshHull(h) -- rebuild the merged hull if parts changed since
- Shapes: all 26 part types. These are solid and bevelled boxes, wedges, domes, cylinders and tubes, forks and spikes; tyres (knobby, slick or foam) on bolted hubs; tank treads with lugs and sprockets; toothed discs and drums; bars and disc-form horizontal spinners on hubs; hinged plates for flippers, lifters and self-righters; hammer, axe and spike heads on arms; crusher beaks; batteries, receivers, glowing status lights; and name plates stencilled in Anton.
- Paint: each part takes
Design.partColor(its paint role from the bot palette, or its own override); "bare" parts show their material. Primary-role parts carry the pattern (stripes, hazard, flames, camo, checker) as a tiling texture in part-local metres. "Split" paints left parts primary and right parts secondary. The finish (matte, gloss, metallic, or worn with chips of bare metal) applies to every painted part. - Handle:
entities[id]={ entity, pivot, meshes, part, inHull }, pluswheels,weapons,srimechs,bounds,radius,smokeandbuildMs. Wheels and spinners spin about their pivot. Plates, arms and jaws hinge at their back end. Hammers and crushers are drawn at their strike pose. - Hull: every structure and armour part is also merged into one hidden
hullModel (CPU copy kept), withhullGeometryandhullRanges[id](contiguous vertex ranges) for the damage system. The parts draw themselves. - Costs: measured on a 40-part bot. A move or rotate takes about 0.03 ms (0.1 ms max), a resize 0.7–2 ms, and an add or remove about 1 ms. A full build takes about 46 ms warm; the first build of a never-seen design takes about 160 ms. Meshes, materials and paint textures are cached by key.
Called by bots.botcore (bot bodies, on every "design" event and at reset) and by the garage's 3D build view.