tabletopMinis.package
- .metadata279 B
- README.md16.6 KB
- SkirmishDemo.component
- api.module
- bake.module
- designs.module
- docs
- figure.module
- geo.module
- manifest.module
- materials
- meshes
This package holds more than this page lists. See all of its files in its world.
README.md
Tabletop Minis
Original miniature figure looks for the units of a tactics, wargame or board game: 9 unit roles in 4 hand-modelled styles (painted fantasy figures, tin toy soldiers, woodland critters, brass clockwork automatons), each standing on its own base, recoloured to any team with a one-line scheme change, with simple procedural poses (idle bob, attack lunge, hit recoil, topple, cheer). 36 pre-baked figures, about 3,300 to 6,800 triangles and 5 to 8 draw calls each, so a full board stays cheap on a phone. Every unit type of tacticsKit maps to a figure of its own (Minis.ROLE_FOR), and any figure renders into a small head-and-shoulders portrait texture for turn order bars, unit cards and rosters (Minis.portrait). Every design is original to this package.
Install it and call one function from any module, component or scene:
local Minis = require("tabletopMinis.api")
local knight = Minis.spawn(nil, { role = "melee", style = "painted", team = 1, position = { 0, 0, 0 } })
local bulwark = Minis.spawn(nil, { role = "tank", style = "tin", team = 2, position = { 2, 0, 0 } })
Minis.pose(knight, "attack")
Minis.pose(bulwark, "hit")
print(Minis.describe("tank", "tin").name) --> Tin Bulwark
Quick start
- Install the package (
zeromind.installAssetwith its guid). local Minis = require("tabletopMinis.api").Minis.spawn(parentEntity, { role, style, team or scheme, height = 1.6 })wherever your game creates a unit, andMinis.pose(unitEnt, "attack")when it acts.
The SkirmishDemo component (tabletopMinis.SkirmishDemo) plays a whole self-running chessboard battle so you can see everything moving: entity.spawn("Skirmish").component.add("tabletopMinis.SkirmishDemo", { styleA = "tin", styleB = "critters" }).
API
local Minis = require("tabletopMinis.api")
| call | does |
|---|---|
Minis.ROLES | melee, ranged, healer, tank, scout, area, leader, heavy, duelist |
Minis.ROLE_FOR | tacticsKit unit type id -> role: soldier melee, scout scout, heavy heavy, sniper ranged, medic healer, grenadier area, shield tank, commander leader, duelist duelist (add your own ids) |
Minis.roleFor(unitType, fallback?) | ROLE_FOR[unitType], else the id itself when it is a role, else fallback (default "melee") |
Minis.STYLES | painted, tin, critters, clockwork |
Minis.SCHEMES | team colour schemes by key, each { label, primary, secondary, trim } (hex colours) |
Minis.SCHEME_ORDER | the scheme keys in team order |
Minis.schemeFor(team) | scheme key for a team index: 1 azure, 2 ember, 3 verdant, 4 amethyst, 5 gold, 6 frost, 7 onyx, 8 rose (wraps) |
Minis.defineScheme(key, { primary, secondary?, trim?, label? }) | add or replace a scheme |
Minis.spawn(parent, opts) | spawns a miniature, returns its entity (see below) |
Minis.setScheme(ent, schemeKeyOrColours) | recolours a spawned miniature; a key or { primary, secondary, trim } |
Minis.pose(ent, name, opts?) | idle, attack, hit, down, cheer, rest (below) |
Minis.currentPose(ent) | the pose playing now |
Minis.describe(role, style) | { name, blurb, role, style }, an evocative unit name and one-line flavour text |
Minis.info(ent) | { role, style, scheme, height, figure, parts } of a spawned miniature |
Minis.despawn(ent) | destroys a miniature and forgets it |
Minis.triangles(role, style) | triangle count of one figure |
Minis.portrait(role, style, scheme, opts?) | renders the figure head and shoulders into a square texture once and answers its handle { guid, width, height, name }; a UI image shows it with src = handle.guid; cached per (role, style, scheme, size, background, angle) (below) |
Minis.clearPortraits(role?, style?) | frees cached portrait textures (all, or one role / style) |
Minis.spawn(parent, opts)
| option | default | meaning |
|---|---|---|
role | "melee" | one of Minis.ROLES |
style | "painted" | one of Minis.STYLES |
scheme | from team | a scheme key, or a { primary, secondary, trim } colour table |
team | 1 | used when scheme is not given, through Minis.schemeFor |
height | 1.6 | metres from the bottom of the base to the crown of the figure's head (raised weapons and banners rise above it) |
base | true | false drops the base; the feet then stand on the entity's origin |
temporary | true | false keeps the miniature in scene saves (use in a scene's build.luau) |
position, rotation, name | the returned entity's transform and name | |
shadows | true | false stops the figure casting shadows |
parent is an entity (or id) or nil. The returned entity's origin is the bottom centre of the base and the figure faces +Z (its right hand is on -X); turn the returned entity to face it another way, for instance rotation = { 0, 1, 0, 0 } faces -Z. Move and turn the returned entity freely; leave its figure child alone, the poses drive it. The base radius is 0.3 * height / 1.0 (0.48 m at 1.6 m tall), so height = 0.85 * cellSize fits one figure per grid square.
Poses
Minis.pose(ent, name, opts?) animates the figure by moving its transform only (no skeleton):
idle: a slow bob and sway, loops.attack: wind-up, lunge forward, return (0.6 s), then back toidle.hit: recoil backwards with a shake (0.5 s), then back toidle.cheer: two hops and a full spin (1.1 s), then back toidle.down: topples backwards onto the base edge and stays down.rest: stands still, stops animating.
Calling the pose that is already playing does nothing, so it is safe to call every frame from a state machine. opts.restart = true replays it; opts.after = "rest" picks what a one-shot returns to; opts.t = seconds applies that single frame of the pose and does not animate (drive it from your own clock or timeline).
Multiplayer
Spawning is deterministic: the same (role, style, scheme, height, base) draws the identical miniature, with nothing random and nothing synced. Keep those values (and positions) in your game's synced state and call Minis.spawn locally on every peer, with the default temporary = true; call Minis.pose on every peer from the same synced events (a move, a hit). Nothing in this package writes synced state.
Portraits
Minis.portrait(role, style, scheme, opts?) renders one figure's head and shoulders (three-quarter view) into a square GPU texture and answers the handle { guid, width, height, name }. Show it with an image widget:
local tex = Minis.portrait("heavy", "tin", "ember") -- a role or a tacticsKit unit type id
{ type = "image", props = { src = tex.guid }, style = { width = 96, height = 96 } }
| option | default | meaning |
|---|---|---|
size | 192 | texture edge in pixels |
background | "scheme" | the scheme's primary, darkened; or "transparent", a hex colour, or { r, g, b, a } |
angle | 22 | camera yaw round the figure, degrees |
fov | 24 | vertical field of view |
team | 1 | picks the scheme through schemeFor when scheme is nil |
Each (role, style, scheme, size, background, angle) renders once and is cached, so calling it from every UI rebuild is free. The handle answers at once and never changes; the picture fills in a moment later (a fraction of a second; a few seconds for a whole roster asked for at once on the web). The figure is staged far below the scene on the minis_portrait render layer with its own lights and an isolated camera; the staging waits until every mesh of the figure is on the GPU (on the web client they stream in), renders, reads the texture back and only marks the portrait ready when the picture shows the figure and two readbacks agree. A blank or still-filling picture is staged again into the same texture, so an image that already shows the guid updates by itself. Stagings run Minis.PORTRAIT_CONCURRENCY (4) at a time.
| call | answers |
|---|---|
Minis.portraitStatus(tex) | "pending", "ready" or "failed" (every attempt read back blank; the next portrait call for it renders it again) |
Minis.portraitReady(tex) | true once the picture is verified |
Minis.awaitPortrait(tex, timeout?) | yields until ready (true) or failed / timed out (false, default 30 s) |
Minis.portraitInfo(tex) | { state, attempts, coverage, meshesResident } |
Minis.portraitCoverage(tex) | share of a texture's pixels that differ from its clear colour (0 for a blank render) |
Minis.clearPortraits(role?, style?) frees the textures.
Unit types (tacticsKit)
| unit type | role | painted | tin | critters | clockwork |
|---|---|---|---|---|---|
| soldier | melee | Oathblade | Tin Sabreur | Thistleback Duelist | Cog Reaver |
| scout | scout | Wildrunner | Tin Outrider | Russet Fox Pathfinder | Spring Strider |
| heavy | heavy | Ironhide Juggernaut | Tin Gatling Gunner | Tuskbreaker Boar | Gatling Colossus |
| sniper | ranged | Thornwood Ranger | Tin Musketeer | Hollowmoon Owl | Brass Arbalest |
| medic | healer | Lamplight Mender | Tin Medic | Badger Herbalist | Mender Automaton |
| grenadier | area | Emberwright | Tin Mortarman | Mole Sapper | Kettle Mortar |
| shield | tank | Bastion Warden | Tin Bulwark | Oakheart Bear | Boiler Golem |
| commander | leader | Banner Marshal | Tin Captain | Hare Herald | Gearwright Regent |
| duelist | duelist | Bladedancer | Tin Fencing Master | Tomcat Swashbuckler | Mainspring Fencer |
Minis.spawn(board, { role = Minis.roleFor(unit.type.id), style = "painted", team = unit.side }) gives each unit type its own figure.
Gallery: roles x styles
| role | painted (fantasy figures) | tin (toy soldiers) | critters (woodland folk) | clockwork (brass automatons) |
|---|---|---|---|---|
| melee | Oathblade: raised longsword, buckler, crested helm | Tin Sabreur: plumed shako, curved sabre | Thistleback Duelist: hedgehog with sword and acorn buckler | Cog Reaver: buzz-saw arm, claw |
| ranged | Thornwood Ranger: hooded, drawn yew bow, quiver | Tin Musketeer: bearskin hat, levelled musket | Hollowmoon Owl: owl archer with feathered cap | Brass Arbalest: drum-fed repeating crossbow, antenna |
| healer | Lamplight Mender: robe, halo, crook lantern, satchel | Tin Medic: heart cap, lamp, bandage satchel | Badger Herbalist: lantern staff, herb satchel, potion | Mender Automaton: halo cog, lantern staff, wrench |
| tank | Bastion Warden: great helm, tower shield, mace | Tin Bulwark: spiked helmet, riveted tower shield | Oakheart Bear: iron half-helm, tower shield, club | Boiler Golem: smoke stacks, tower shield, piston hammer |
| scout | Wildrunner: hood, flaring cloak, twin daggers, sprint | Tin Outrider: kepi, short cape, spyglass | Russet Fox Pathfinder: cloak, scarf, twin knives, bushy tail | Spring Strider: coil-sprung legs, antenna, scarf |
| area | Emberwright: pointed hat, beard, ember orb staff, fireball | Tin Mortarman: bomb in arms, field mortar beside him | Mole Sapper: goggles, bomb pack, lit bomb | Kettle Mortar: back-mounted mortar, glowing shell |
| leader | Banner Marshal: plumed helm, cape, banner and sword | Tin Captain: bicorne, epaulettes, colours and sword | Hare Herald: circlet, cape, banner and sword | Gearwright Regent: gear crown, cape, cogwheel banner |
| heavy | Ironhide Juggernaut: horned bucket helm, fur mantle, spiked great maul | Tin Gatling Gunner: pickelhaube, hand-cranked rotary gun, ammo drum on the back | Tuskbreaker Boar: tusks, bristle crest, great wooden mallet | Gatling Colossus: boiler pack and chimney, rotary-cannon arm, huge fist |
| duelist | Bladedancer: plumed cavalier hat, short cape, rapier lunge, parrying dagger | Tin Fencing Master: plumed hat, short cape, rapier lunge | Tomcat Swashbuckler: tuxedo cat, plumed hat, rapier lunge, curling tail | Mainspring Fencer: slim automaton, rapier lunge, spinning balance wheel |
Bases: painted figures stand on grassy round bases with pebbles, tin soldiers on stamped green plates, critters on cut log slices with a mushroom, clockwork on brass gear plinths. Every base carries a band in the team's primary colour, so the team reads from straight above.
Schemes
| key | primary | secondary | trim |
|---|---|---|---|
| azure | royal blue | parchment white | gold |
| ember | crimson | soot black | gold |
| verdant | forest green | wheat | bronze |
| amethyst | violet | lilac | silver |
| gold | marigold | dark brown | cream |
| frost | ice blue | white | steel |
| onyx | charcoal | red | silver |
| rose | rose pink | blush white | gold |
Primary colours tunics, shields, flags and base bands; secondary capes, hoods, plumes and emblems; trim belts, fittings, crowns and shield rims. Any colours work: Minis.setScheme(ent, { primary = "#118877", secondary = "#ffee88", trim = "#cccccc" }).
How it is built
Each figure is modelled in Luau (designs on top of the figure parts kit and the tiny geo mesh builder) and baked once by bake into mesh assets under meshes/ with vertex colours: base, baseTeam, body, primary, secondary, trim and one glow_* mesh per glow colour. The body uses one shared material per style (matte paint, glossy enamel tin, soft fur, metallic brass); the team parts use one shared white material per style tinted per entity through the Model tint, so a scheme change is a tint change and never a new material. manifest (generated) names every asset by literal, so an install carries all of them.
To change a design, edit designs.module, then run require("@root::tabletopMinis.bake").all() in the authoring world.
Contents
api.module: the public API above.SkirmishDemo.component: self-playing chessboard skirmish (the example guide's code).meshes/,materials/,manifest.module: the baked figures.designs.module,figure.module,geo.module,bake.module: how the figures are modelled and baked.tabletopMinisTests.testSuite: the test suite (catalogue, unit type mapping, spawning and schemes, poses, portraits).docs/: guides "How to give tactics game units miniature figure looks with team colours" and "Example: a chessboard skirmish with tin soldiers vs woodland critters".
Version
1.1.1
Changelog
- 1.1.1: portraits no longer come out blank or half-drawn on the web client. Before, the staging rendered in the figure's first frames and cached that picture forever; on the web the figure's meshes are still streaming in then (and a taken-down figure gives its buffers back, so a retry was just as cold), and a whole roster staged at once left parts out. Now each staging waits until every mesh of the figure is on the GPU, reads the texture back and marks the portrait ready only when it shows the figure and two readbacks agree, re-rendering into the same handle otherwise; stagings run four at a time. New:
Minis.portraitStatus,portraitReady,awaitPortrait,portraitInfo,portraitCoverage. Docs drop thefitprop theimagewidget ignores. Tests cover readiness and that a blank result is never cached. - 1.1.0: two new roles in all four styles,
heavy(a two-handed brute or heavy gunner on a wide planted stance) andduelist(a deep fencing lunge with a rapier), so there are 36 figures and every tacticsKit unit type has a silhouette of its own;Minis.ROLE_FORandMinis.roleFormap the nine tacticsKit unit type ids to roles 1:1;Minis.portraitrenders a cached head-and-shoulders portrait texture for UI images, andMinis.clearPortraitsfrees them; the SkirmishDemo fields heavy and duelist; a test suite (tabletopMinisTests); the demo lineup shows all 36. - 1.0.1: poses animate again. The pose driver was a task owned by whichever script posed first (a component's
startin edit mode, anexecutecall), so when that script ended or entering play rebuilt the scene, the driver died while a module flag still said it was running and every miniature stayed frozen for the session; it is now a system task that the nextposerestarts whenever it is no longer live, and a paused play session still freezes poses.currentPosenow readsidle(orafter) once a one-shot ends. The SkirmishDemo board sits 2 cm above its entity so its tiles no longer z-fight with a ground at the same height. - 1.0.0: first release. 7 roles x 4 styles (28 original figures), 8 team schemes plus
defineScheme,spawn/setScheme/describe/pose/info/despawn, six procedural poses, baseless spawning, the SkirmishDemo component and two guides.