# Main Street: Player Shopfronts, Awnings, Signs and Street Layouts Kit
A street of player shops. Every player in the world (or in their room) gets a shopfront standing side by side with everyone else's, so friends can show friends their shops. Each front is drawn from a small record: facade style, awning, sign, palette, window display, shop name, a level badge and a neighbourhood. The street stands in a real place: a road with kerbs and sidewalks on both sides, ground that reaches the horizon, houses and trees behind the fronts, lamps, benches and planters along it, and a fog and sky that suit a cosy town. Cosy, charming and all-ages, built from chunky rounded shapes and flat colours, cheap enough for a tablet.
Install it for an idle shop game, a bakery or cafe game, a town hub, a lobby where friends compare progress, or a gallery of shopfront, awning and sign styles.
## What you get
- **10 facade styles**: `brick`, `stucco`, `timber` (timber frame with a jettied upper floor), `tiled`, `clapboard` (painted wood boards), `stone`, `glass` (modern glass), `cottage` (thatch, shutters and flower boxes), `mansard` (Parisian slate mansard with dormers and iron balconettes), `deco` (Art Deco: fluted fins, chevron frieze, stepped parapet and sunburst).
- **6 awnings**: `striped`, `scalloped`, `flat` (flat canvas with fringe), `dome` (round dome canopy), `twoTone` (two-tone with a zigzag valance), `none`.
- **6 signs**: `hanging` (board on chains under an iron bracket), `fascia` (flat fascia board), `medallion` (round medallion between the windows), `window` (gold lettering painted on the shop window), `chalkboard` (A-frame chalkboard on the pavement), `neon` (a dark board ringed by glowing tubes, the name glowing in the tube colour).
- **3 level badges**: `star` (gold star on a plate), `rosette` (a prize rosette with ribbon tails), `shield` (a gold-edged crest). Each shows the front's level. A front picks its own (`record.badge`), the street's `badge` setting covers fronts that name none, and `badgeFor(peer, record, info)` lets the game choose per front (by rank, by team).
- **4 environments** (`environment`, default `town`): `town` (a park with a hedge and trees across the road, rooftops and a church spire behind), `seaside` (a promenade railing, beach, parasols, the sea with boats and a lighthouse, pastel beach houses and pines), `hillside` (a dry stone wall and vineyard rows across the road, houses climbing the slope, cypresses, rolling hills and a turning windmill), `none` (the street alone, for a game that draws its own surroundings). Every look carries the road on past both ends, the far kerb and sidewalk with lamps and benches, and its own fog and sky.
- **5 street layouts**: `row`, `curve` (gentle curve), `twoSided` (shops on both sides of the road), `plaza` (corner plaza with a fountain and a tree), `hillside` (hillside steps).
- **10 palettes**: `strawberry`, `mint`, `butter`, `lavender`, `terracotta`, `sage`, `peach`, `cocoa`, `sky`, `rose`.
- **Props**: lamp posts, planters, benches and bicycles between the shops; each front can add its own (`planter`, `bicycle`, `bench`, `lamp`, `crates`).
- **Window display**: up to 8 products on two lit shelves. 11 bakery products ship (`bread`, `baguette`, `bun`, `croissant`, `cake`, `cupcake`, `pie`, `cookie`, `jam`, `milk`, `gift`); a game registers its own with a shape and colours.
- **Names without typing**: a name is a catalog key (with params) or generated from translated word parts, so each viewer reads it in their own language ("The Golden Crust" / "A Casca Dourada"). Free text only shows where the game allows it. Every name label breaks onto two lines inside its board, so long Portuguese names and the pseudo-locale's bracketed text stay readable.
- **Neighbourhoods with articles**: the street sign names the neighbourhood and greets in the viewer's language with the right contraction ("Welcome to Harbour!" / "Boas-vindas ao Porto!", "Boas-vindas à Beira-Rio!"); an empty lot reads "Este cantinho no Pomar / na Rua do Mercado espera a loja de um amigo".
- **Empty lots** with a little lawn and sign wait for friends.
- **English and Brazilian Portuguese** for every sign and label, switched live; every pt-BR line reviewed.
- **A gallery** (`gallery.scene`) with every facade, awning, sign, badge, palette, layout and environment side by side, and one setting (`look`) that changes the whole gallery live.
- **A workflow and a skill**: `add-a-street-of-player-shopfronts` (run with `zero workflow start`) and the agent skill `add-a-street-of-player-shopfronts-to-my-game` walk an agent through adding a street to a game, step by step, ending in a two-client test.
## Quick start
```luau
local Street = require("shopfrontStreetKit.api")
-- at every play start, on every peer (a street left by the previous play session is rebuilt)
Street.configure({ layout = "curve", origin = { 0, 0, 0 }, environment = "seaside", badge = "rosette" })
Street.setMyFront({
style = "mansard", awning = "dome", sign = "neon", palette = "mint",
display = { "bread", "croissant", "cake" },
name = { parts = { pattern = "adj_noun", adj = "golden", noun = "crust" } },
level = 3, badge = "shield",
})
Street.on("added", function(front) print(front.name, "opened in slot", front.slot) end)
```
Or place the `ShopStreet` component on an entity (its position and yaw place the street; every field is one setting, and a change reaches the street live) and call `setMyFront` from the game.
## Multiplayer
Each player publishes ONLY their own record (channel `shopfrontStreetKit.v1` on the engine multiplayer surface). The relay names the sender of every message, so a record is always filed under the player who sent it and nobody can change anyone else's front. Every peer validates every record against the catalog and draws all of them. A player leaving removes their front; slots fill in join order and keep their positions (a leaver frees a slot, nobody moves). For roomsKit rooms, `Street.setRoom(RK.myCode())` shows only the players of that room; `Street.setFilter(fn)` takes any predicate. `mode = "local"` plus `fillNeighbours(n)` gives single player and galleries a full street of fake neighbours.
## Play sessions
Module state outlives a play session in this engine; entities do not. `configure()` and `street()` notice a street whose entities are gone and build a fresh one, so calling `configure()` at every play start just works, and a second play in the same session needs no extra call (no `stop()` first). A street whose root disappears also stops its own timers.
## API (`require("shopfrontStreetKit.api")`)
| Call | What it does |
|---|---|
| `configure(opts)` | Make or reconfigure the shared street. `layout`, `slots` (1 to 16, default 8), `origin`, `yaw`, `parent`, `environment` (`town`, `seaside`, `hillside`, `none`; default `town`), `environmentAir` (default true: the look's fog, and a sky, each only when the scene has none of its own), `badge` (`star`, `rosette`, `shield`; default `star`), `badgeFor(peer, record, info) -> style`, `props` (a list, a comma separated string, `true` for all four, `false` for none), `emptyLots`, `streetSign`, `neighbourhood`, `room`, `filter`, `allowFreeText`, `cullDistance` (90; 0 never), `cullMode` (`hide` switches a far street off, `unload` takes its entities down and draws it afresh when the camera returns), `curveRadius`, `hillRise`, `labelScale`, `tagline`, `signKey`, `keepClear` (a list of `{ x, z, radius }` world discs, such as the game's own play area or diorama: the backdrop hills, the windmill and the church tower step back until none stands in one), `mode` (`multiplayer` or `local`). |
| `setMyFront(record)` | Publish my front (merged into what I set before); `nil` takes it down. |
| `myFront()` | My validated record. |
| `setLayout(name)`, `setEnvironment(look)`, `setBadge(style, fn?)`, `setRoom(id)`, `setFilter(fn)` | One setting each. |
| `addNeighbour(id, record)`, `fillNeighbours(n, seed)`, `removeNeighbour(id)`, `clearNeighbours()` | Fake neighbours, local to this screen, after real players. |
| `fronts()` | `{ id, slot, record, mine, fake, peer, name, pose, entity }` in slot order. |
| `on(event, fn)` | `added`, `removed`, `moved`, `changed`, `full`, `culled`. Returns a stop function. |
| `viewOf(slot?, fit?)`, `slotWorld(slot)` | Camera pose for one front or the whole street; a slot's position and facing. `fit = { aspect, fov, margin }` (width / height, vertical degrees, share of the half-frame) steps the whole-street view back until every front, full width and height, is inside that screen, so a phone held upright still sees every shop. A camera standing at a whole-street view the street handed out is never culled, however far back the fit stood it. |
| `new(opts)` | An extra local street (galleries, menus, previews): `:put(id, record, { fake = true })`, `:remove(id)`, `:set(opts)`, `:destroy()`. |
| `registerProduct(id, { shape, color, color2 })` | Your own window display products. Shapes: `bun loaf cake cupcake croissant pie jar cookie box bottle`. |
| `randomFront(seed)`, `randomName(seed)`, `nameText(name)` | Generated fronts and names; the name in this viewer's language. |
| `stop()` | Tear the shared street down. |
`STYLES`, `AWNINGS`, `SIGNS`, `BADGES`, `ENVIRONMENTS`, `LAYOUTS`, `PALETTES`, `PROPS`, `FRONT_PROPS`, `SHAPES` list every id.
Record: `{ style, awning, sign, palette, display, name, level, badge, neighbourhood, prop, slot? }`. Name: `{ key = "<namespace>.<key>", params = {...} }`, `{ parts = { pattern, adj, noun, noun2, owner, place } }` or `{ text = "..." }` (only shown with `allowFreeText`). Patterns: `adj_noun`, `noun_and_noun`, `owner_noun`, `noun_of_place`; the word lists are `catalog.NAME_ADJECTIVES`, `NAME_NOUNS`, `NAME_OWNERS`, `NAME_PLACES`, `NEIGHBOURHOODS`. A game's own neighbourhood names go in its catalog as `shopfront_names.hood_<id>` with its gender per language in `hood_<id>_g` (`m` or `f`), which is what the greeting and the lot sign contract with.
## Components
- `ShopStreet`: the scene's street. Fields `layout`, `slots`, `environment`, `environmentAir`, `badge`, `props`, `emptyLots`, `streetSign`, `neighbourhood`, `mode`, `fakeNeighbours`, `previewInEdit`, `cullDistance`, `seed`. In play it is the shared street; in edit mode it previews generated fronts (drawn from the editor's tick, so the preview shows while the editor holds the gameplay clock).
- `ShopGallery`: the gallery's one setting, `look` (`town`, `seaside`, `hillside`, `none`), changing every row, the stage and the air live.
## Performance
One model entity per front (one Generator; repeated parts draw instanced, materials shared per colour) plus 2 to 4 text labels, one ground model and one environment model per street, made of plain coloured materials. Nothing runs per frame: a change schedules one refresh, a language change only rewrites labels, a 1 Hz look at the peer list notices leavers, and a 2 Hz check culls the street while the camera is further than `cullDistance`. Measured on desktop (dev build, 1920x1080): the demo street (8 fronts on the `town` environment) at 4.5 ms engine CPU per frame; the whole gallery with `cullMode = "unload"` at 8.1 ms (60 fps, vsync bound). An entity switched off still costs the renderer each frame, so a scene that holds many streets should use `cullMode = "unload"`.
## Inside
`api` (public surface), `street` (one street: slots, layouts, drawing, labels, culling), `environment` (the place: ground, far side, backdrop, landmark, air), `net` (owner-only records), `records` (validation, names, neighbourhood phrases), `build` (the modelling), `catalog` (every choice), `gallery` + `gallery.scene` + `ShopGallery` (everything side by side), `ShopStreet` component, guides `how-to-add-a-street-of-player-shops` and `multiplayer-shop-street-example`, the workflow `add-a-street-of-player-shopfronts` and the skill `add-a-street-of-player-shopfronts-to-my-game`, test suite `shopfrontStreetKit`, `locales/en`, `locales/pt-BR` (every line reviewed) and `glossary/pt-BR.json`.