Log inGet started
Package

boardKit.package

README.md

boardKit

A race board game kit for multiplayer Zero worlds: a track of spaces, pawns that race along it, and turns, in one call. Tracks are generated from a shape and a length, so any number of spaces works: a loop, a winding snake, a spiral, a figure eight that crosses itself over a bridge, a path that splits into two ways the player chooses between and joins again, and a climb grid numbered back and forth with ladders up and slides down. Fifteen space types (boost, mud, nap, fortune card, roll again, swap with the leader, warp gate, safe haven, toll, treasure, ladder, slide...) are placed by a seeded generator you can override space by space. Nine pawn looks, five board themes and four ways to move sit behind one interface: change one setting to change the look. One host runs the rules and the board state replicates, so everyone sees the same race, a joiner sees it as it stands and a seat whose player leaves is skipped or freed. The board takes a number of steps (board:move(seat, n)), wherever the number came from: dice, a spinner, cards or a quiz. Two guides ship inside the package.

Version 1.0.12 (BK.VERSION).

Quick start

  1. Install boardKit.package into /source (search ZeroMind for "boardKit", or install guid of the package from the world "Roll and Race: Board Tracks, Spaces and Pawns Kit").
  2. Put a board in your scene's build.luau:
local BK = require("boardKit.api")

function content()
    local cam = entity.spawn("BoardCamera")
    cam.component.add("Camera", {})
    cam.localPosition = { 0, 1.5, 1.3 }
    cam.localRotation = { -0.42, 0, 0, 0.91 }

    BK.Board { name = "Race", track = "loop", spaces = 40, theme = "meadow", pawns = "wooden_people", seats = 4, quickRoll = true }
end
  1. Press play. The panel shows the seats and whose turn it is; press Roll (a plain 1 to 6) and watch the pawn hop. Friends who join take the next seat.

Your game moves pawns itself, from any peer:

local b = BK.board("Race")
b:move(b:state().turn, myDiceResult)

Change one word to change the game: track = "fork", theme = "space", pawns = "drones", movement = "fly".

Game rules in a few lines

Hooks run on the board's host; register them on every peer (for example in onLoad of the scene's entrypoint.luau):

local BK = require("boardKit.api")

function onLoad()
    BK.rules("Race", {
        canMove = function(b, seat, n) if n == 0 then return false, "Roll first!" end end,
        onLand = function(b, seat, space, g)
            if space.type == "toll" and g.seats[seat].coins == 0 then
                g:back(seat, 2)              -- can't pay? walk back instead
                return false                 -- and skip the toll's own effect
            end
        end,
        onWin = function(b, seat) print(b:seatName(seat) .. " wins!") end,
    })
    BK.on("landed", function(e) print(e.text or (e.seat .. " landed on " .. e.type)) end)
end

Settings

Every setting is a field of the BoardTrack component; BK.Board{...} takes them all plus name, position and rotation (a yaw in degrees or a quaternion). Change one live with BK.board(name):set(key, value).

settingdefaultwhat it does
track"loop"loop, snake, spiral, figure8, fork, climb
spaces40spaces including start and finish (10 to 400; fork 18+, climb 12+)
theme"meadow"meadow, candy, space, pixel, tidepool
pawns"classic"classic, wooden_people, animals, chess, pegs, blobs, pixel, drones, gems
movement"hop"hop, slide, blink, fly
rules"race"race (first home wins) or podium (play on for every place)
seats4pawns, 1 to 8
seed0the space layout and props; the same seed builds the same board everywhere
size1.2the board's longest side in metres
scale1overall scale on top of size
finish"overshoot"overshoot (stop on the finish), exact (a move past it is not made), bounce (walk back the extra)
forkChoice"player"player (pause and ask), first / long, short, random, alternate
cards"fortune"fortune (built-in deck), event (only the drawCard event, your game decides), none
turns"strict"strict (only the seat whose turn it is) or free
coins0coins each seat starts with
special0.4share of spaces that do something
spaceTypesallthe space types the generator may use, e.g. { "boost", "back", "skip" }
spaceListnonemanual spaces: { [5] = "boost", [9] = { type = "warp", to = 20 }, [12] = { type = "back", n = 4 } }
colsautoclimb grid columns
numbers"all"numbers printed on all spaces, only special ones, or none
decortruethemed props round the board's edge
speed1animation speed
leave"skip"a seated player leaves: skip their seat, or free it for anyone
autoSeattrueplayers take seats in order as they join
showUitruethe built-in panel (seats, turn, last event, fork buttons)
panel"left"where the panel sits: top-left, top-right or along the top; compact on phones; never bottom-centre
quickRollfalsea Roll button with a plain 1 to 6, for trying the board
demo0seconds between automatic moves (a board that plays itself)
config"host"who may change settings live with :set (and the gallery): the host only, or anyone
title""a title line on the panel

The live board: BK.board(name)

callwhat it does
:move(seat, n)move a pawn n steps (refused, with a reason toast, when it is not that seat's turn)
:choose(seat, way)answer a fork: way 1 (the long way) or 2 (the short cut)
:state(){ seats = { { pos, coins, skips, active, finished, place, peer, name } }, turn, round, over, winner, places, pending }
:pawnPosition(seat) / :spacePosition(i)world positions (the pawn as drawn now, mid-hop included)
:setTurn(seat) :restart(seed?)turn control and a new game
:sit(seat?, peer?) :leave(peer?) :freeSeat(seat)seat the local player in a chosen seat (the host may name a peer), stand up, or free a seat; with autoSeat = false nobody sits until the game asks
:setLocalUi(on) `:setPanel("left""right"
:teleport(seat, i) :addCoins(seat, n) :skipNext(seat) :extraTurn(seat)game-side effects
:set(key, value)change a setting live (layout settings start a new game)
:space(i) :track() :layout()what a space is: { index, type, n, to, name, text }
:isBusy()pawns still animating
:mySeat() :seatName(s) :seatColor(s) :isHost() :game()who is who; the rules model on the host

Events: BK.on(name, fn, opts?)

opts is a key string (a later on with the same event and key replaces this listener) or { owner = entity } (the listener ends once that entity is gone): pass one from code that runs again in every play session, such as a component or a scene's onLoad, so listeners do not pile up.

Raised on every peer as the state arrives, each with { board, seq, name, seat?, text? ... }: turn (seat, round), move, moved (from, to, path, steps), landed (space, type), arrived (the pawn finished animating), boost, back, warp, ladder, slide, swap (other), skipNext, skip, again, drawCard (card, title, text), toll, bonus, choice (options), chose, blocked (exact finish), refused, finished (place), won, over, sat, left, freed, ready. "*" listens to all.

Rule hooks: BK.rules(name, hooks)

canMove(b, seat, n, g) returns false, "reason"; onLand(b, seat, space, g) and onCard(b, seat, card, g) return false to cancel the built-in effect; onTurn(b, seat, g), onWin(b, seat, g), onMove(b, seat, path, g), onStart(b, g), onSit(b, seat, peer). g is the rules model: g:forward(seat, n), g:back(seat, n), g:teleport(seat, i), g:addCoins(seat, n), g:addSkip(seat), g:extraTurn(seat), g:leader(), g:standings().

Catalog

Every entry is also in BK.CATALOG; filter with BK.variants{ kind = "track" | "space" | "pawn" | "theme" | "movement" | "rules", tag = "cute", search = "words" }. Names are forgiving: "Figure Eight", "zig zag", "Wooden People", "sci-fi", "roll again" all resolve (BK.normalize(setting, name)).

Tracks (track)

idnameshape
loopLoopa rounded rectangle; the finish sits just behind the start
snakeWinding Snakerows back and forth joined by round turns
spiralSpiralfrom the outside in; the finish is the centre
figure8Figure Eightan eight whose second crossing passes over a bridge
forkFork in the Roadsplits into the long way and a risky short cut, then joins again; the player picks
climbClimb Grida numbered grid read back and forth, upwards, with ladders and slides

Spaces

idnameeffect
start / finishStart / Finishwhere pawns begin; first home wins
normalPathnothing
boostTailwindforward n (2 or 3)
backMud Patchback n (2 or 3)
skipNap Spotmiss the next turn
cardFortunedraw a fortune card
againLucky Rollanother turn
swapSwitcherooswap places with the leader
warpWarp Gatejump to the linked space ahead
safeSafe Havennobody can swap you off it
tollToll Gatepay n coins
bonusTreasurecollect n coins
ladder / slideLadder / Slideclimb up / slide down to the linked space (climb grid)

Effects that move a pawn do not chain: the space it is moved to does not act. The fortune deck (16 original cards, BK.Fortune.CARDS) moves pawns forward or back, sends them to sleep, gives another turn, pays or takes coins, treats everyone or swaps with the leader; add cards with BK.Fortune.register{ id, name, text, effect = { kind, n } }.

Pawns (pawns)

idnamelooks like
classicClassic Pawnsglossy turned pawns with a gold collar
wooden_peopleLittle Wooden Peoplepeg-doll folk with a painted tunic, cap and rosy cheeks
animalsAnimal Friendsa round little animal per seat: bunny, bear, cat, frog, piglet, chick, fox, mouse
chessChess-style Pieceslacquered king, queen, rook, bishop and knight, one per seat
pegsPegstapered pegs with a ball top
blobsCartoon Blobssquishy jelly blobs with googly eyes
pixelPixel Tokensvoxel heroes made of blocks
dronesHover Droneshovering quad-rotors with spinning rotors
gemsCrystal Gemsfaceted crystals on a brass setting

Seat colours: red, blue, green, yellow, purple, orange, teal, pink.

Themes (theme)

idnamelooks like
meadowMeadow Woodwalnut and moss, cream tiles, trees, flowers and mushrooms
candySugar Sweetsstrawberry frosting, glossy candy-button tiles, lollipops and gumdrops
spaceSpace Stationgunmetal plates, glowing hex tiles and icons, antennas and planets
pixelPixel Retroa chunky arcade board, block tiles, voxel trees and coins
tidepoolTide Pooldriftwood, a sea-glass inlay, shells, starfish and coral

Movement (movement)

hop (a hop onto each space), slide (a smooth glide), blink (vanish and pop up), fly (one high arc). Pawns that share a space spread out round it.

What you get

partwhat it is
boardKit.apithe one interface
BoardTrack componentone multiplayer board: host rules, replicated state, drawing, animation, panel
BoardGallery componenta Gallery button (top-right) opening a side panel that flips through every track, space type, pawn, theme and movement and applies each live to a board (mouse, touch, gamepad)
Pawn scene moduleone still pawn of any look, modelled with quick geometry from the same design data
rules modulethe pure, tested rules model (BK.game{...} makes one without a board)
tracks, spaces, fortune modulestrack shapes, space types and layout, the fortune deck
themes, pawns, render, geo, materials modulesthe looks and the run-time drawing
catalog, registry, rng modulesnames, the event bus and network channel, seeded randomness
boardKit test suitethe rules and generators, run with zero tests run boardKit

Multiplayer

The peer that owns the board's entity (the room host for a scene board) runs the rules; every request (move, choose, sit, set...) from another peer travels on the boardKit.req channel and the host applies it. The public state (positions, coins, turn, the last 40 events) is one synced field, so a joiner sees the board as it stands. If the host leaves, the next host rebuilds the game from that state. A seat with no player can be moved by anyone (hot seat); a seated player's pawn only by them or the host.

Guides

Two guides ship inside the package (guides/), found by searching for what you want to make:

  • How to make a board game with a track, spaces, pawns and turns: board shapes, space types, moving pawns from your own dice, events, rule hooks, seats, the panel and the gallery.
  • How to make a dice race board game, step by step: a four-player dice race with a fork-in-the-road track, a Roll button with a random 1 to 6, fortune cards and house rules.

Versions

  • 1.0.12: empty seats sit out and nobody takes someone else's turn. Once anyone holds a seat, every seat nobody sits in is skipped (two friends on a four-seat board no longer get stuck on Green's turn), and comes back when a player takes it; a board nobody sits at keeps every seat. A player moves or chooses only for their own pawn on their own turn; setTurn, teleport, addCoins, skipNext, extraTurn and freeing a seat come only from the host, and a player's restart works once the race is over. BK.on(name, fn, opts) takes a key or an owner entity. Found in a two-computer test of Game Night.
  • 1.0.11: the pawn and space sound descriptions upload in full (1.0.10 could carry them empty).
  • 1.0.10: each pawn and space sound carries a description of what it is and when it plays (1.0.9 shipped them with placeholders).
  • 1.0.9: painted board art and sound. Every theme lays a painted ground over the board field (meadow clover and wildflowers, candy frosting and sprinkles, space deck plating, pixel grass, tide pool sand), tiled at a fixed size so every track shape gets the same detail (art = false in Render.board opts leaves it out). Pawns sound as they move: a wooden tock on every hop and a knock when they settle, and spaces sound their effect: a whoosh for boosts, ladders and warps, a slide whistle for going back, a yawn for a nap, a reveal for a fortune card, coins for treasure and tolls (sound = false, volume).
  • 1.0.8: tap or click a space or a pawn: a card by the finger says what it is ("Space 20 · Treasure: collect 2", "Blue · space 7 · 2 coins") and the tapped event carries it ({ board, kind = "pawn" | "space", seat?, index?, text }); a tap a button already took is not counted. b:setLocalInsets({ top, ... }) starts the panel below another kit's HUD, and the device safe area is kept. Checked by touch on an upright phone.
  • 1.0.7: the dice race example rolls real physics dice: it installs diceKit beside boardKit, connects the tray to the board with canRoll and onRolled, and walks the fork, the exact finish and Play again (followed word for word in a fresh world, every step checked in play). Its house rule pays double for treasure on the long way (lane == "a"), where the treasure is.
  • 1.0.6: a second player's seat, move and choice always reach the board. Each board now listens for the requests sent to it from its own component instance and applies them in its own update; the registry module's listener could stay bound to an older copy of the registry after the kit was reloaded, so a non-host player's sit reached the host and was dropped (found in a two-client test in Game Night, where the second player's pawn never took their chair). The registry's listener steps aside for boards that listen themselves.