Log inGet started
World

Mill to Market: Production Buildings, Chains and Idle Earnings Kit

Merged

productionKit 1.3.0: team buildings for RTS games (team-only queues, team economyKit accounts, host-side queueFor, trainer kinds, richer jobDone)

#1
Author
claude-code @ auraAgent
Opened
Nov 2, 2026
From
contrib-01m6f0n7
Into
main
Merged
Nov 2, 2026

productionKit 1.3.0: team buildings for RTS games (backwards compatible: a world that sets no team behaves exactly as 1.2.1).

Why: an RTS wants each team's barracks to be a productionKit building whose training queue trains that team's units. Until now any player could queue at any shared-town building, coins came out of the requesting player's wallet, and a computer opponent (a team with no player) could not queue at all.

What changed

  • Building option team (string) on Production.building{...} and a new team field on the ProductionBuilding component. Kept in the building record (team), so late joiners and a new works see it.
  • Team membership is decided by game code on the works' machine: Production.setTeamOf(keyOrPeer, team), Production.teamOf(keyOrPeer), or setup{ teamOf = function(playerKey) return team end }. Only that team's players may queue, cancel, upgrade or pause a team building; others get code notYourTeam ("That building belongs to another team", translatable as productionkit.reasons.not_your_team).
  • Team accounts: currency costs of a team building's jobs and upgrades are taken from the team's shared economyKit account (setup{ teamAccount = fn }, default "acct:" .. team) with economyKit 1.1.0's all-or-nothing Economy.debit, and refunds go back with Economy.credit. The queue entry records the account (acct), so a refund after a host change still goes to the right place. A team building with no town works with the team's own town "team:<team>"; coins that town makes are credited to the team account. The per-player wallet path is untouched.
  • Host-side queueing for AI opponents: Production.queueFor(buildingId, job, opts?, cb?) and Production.cancelFor(buildingId, which, cb?) on the works' machine (opts.account, opts.by, opts.free), with the same { ok, ... } / refusal shape (notWorks elsewhere). Works gains queueJob, queueFor, cancelFor, cancelJob, debitAccount, creditAccount, refreshFunds.
  • Game-defined trainer kinds: defineBuilding takes base (start from another kind's definition, e.g. base = "barracks"), jobs as a list { { id, name, cost, time, outputs? } } (or a map), slots, and art (draw it as one of the kit's twelve kinds). category = "trainer" draws as a barracks. Art resolves this with Art.artKind, so the barracks art is used in both looks (same part lists, same roof height).
  • jobDone (view, every machine) and works.jobDone now carry id/building (besides b), team, buildingKind, and the building's position, yaw (degrees) and door (1.5 m in front of the entrance) from the new Production.placeOf(id). The existing kind = "jobDone" field of works.jobDone is unchanged.
  • Queue panel: for a team building, job affordability is checked against the team account (read live with Economy.balanceOf, else the funds the works copies into the record each second), never the player's own wallet.
  • Version 1.3.0 in package.yaml, Production.VERSION, README; README "Team buildings for RTS games" section, Reference and Changes entries; English catalog keys for the new refusals.

Tests: productionKitTests gains five tests (team permission, team-account charging/refunds incl. a host change and team-town payout, queueFor/cancelFor, jobDone payload incl. the view's, a game's own trainer kind from base = "barracks"); the fake bank accepts acct: keys with economyKit 1.1.0's debit/credit shape. Also exercised live in play with two team barracks (rustic and scifi): permission refusals, acct charges/refunds, queueFor/cancelFor and jobDone payloads.

Needs economyKit >= 1.1.0 (shared "acct:" accounts) for team accounts; that change is a separate PR to economyKit's own world. Without it a team building's queue is refused with code teamAccount rather than charging the wrong wallet.

Source world: 7d1bd9e7-e085-42da-8a1d-536b9495b8b3 Contributed paths:

  • productionKit.package/ProductionBuilding.component/init.luau
  • productionKit.package/ProductionHost.component/init.luau
  • productionKit.package/README.md
  • productionKit.package/art.module/init.luau
  • productionKit.package/catalog.module/init.luau
  • productionKit.package/locales/en/productionkit.json
  • productionKit.package/package.yaml
  • productionKit.package/production.module/init.luau
  • productionKit.package/productionKitTests.testSuite/init.luau
  • productionKit.package/sim.module/init.luau
  • productionKit.package/view.module/init.luau
  • productionKit.package/works.module/init.luau
  • productionKit.package
  • productionKit.package/ProductionBuilding.component
  • productionKit.package/ProductionHost.component
  • productionKit.package/art.module
  • productionKit.package/catalog.module
  • productionKit.package/production.module
  • productionKit.package/productionKitTests.testSuite
  • productionKit.package/sim.module
  • productionKit.package/view.module
  • productionKit.package/works.module

22 files changed

  • ChangedproductionKit.packageFolderBeforeAfter
  • ChangedproductionKit.package/ProductionBuilding.componentFolderBeforeAfter
  • ChangedproductionKit.package/ProductionBuilding.component/init.luau3.5 KB → 3.7 KBBeforeAfter
  • ChangedproductionKit.package/ProductionHost.componentFolderBeforeAfter
  • ChangedproductionKit.package/ProductionHost.component/init.luau17.7 KB → 18.4 KBBeforeAfter
  • ChangedproductionKit.package/README.md34.0 KB → 40.5 KBBeforeAfter
  • ChangedproductionKit.package/art.moduleFolderBeforeAfter
  • ChangedproductionKit.package/art.module/init.luau105 KB → 106 KBBeforeAfter
  • ChangedproductionKit.package/catalog.moduleFolderBeforeAfter
  • ChangedproductionKit.package/catalog.module/init.luau26.6 KB → 29.5 KBBeforeAfter
  • ChangedproductionKit.package/locales/en/productionkit.json6.5 KB → 6.6 KBBeforeAfter
  • ChangedproductionKit.package/package.yaml1.1 KB → 1.1 KBBeforeAfter
  • ChangedproductionKit.package/production.moduleFolderBeforeAfter
  • ChangedproductionKit.package/production.module/init.luau41.2 KB → 49.2 KBBeforeAfter
  • ChangedproductionKit.package/productionKitTests.testSuiteFolderBeforeAfter
  • ChangedproductionKit.package/productionKitTests.testSuite/init.luau41.9 KB → 55.4 KBBeforeAfter
  • ChangedproductionKit.package/sim.moduleFolderBeforeAfter
  • ChangedproductionKit.package/sim.module/init.luau16.1 KB → 16.2 KBBeforeAfter
  • ChangedproductionKit.package/view.moduleFolderBeforeAfter
  • ChangedproductionKit.package/view.module/init.luau4.5 KB → 4.6 KBBeforeAfter
  • ChangedproductionKit.package/works.moduleFolderBeforeAfter
  • ChangedproductionKit.package/works.module/init.luau42.7 KB → 52.7 KBBeforeAfter

Checks

No checks have been posted.

Reviews

No reviews yet.

Conversation

No comments yet.

Sign in to comment or review.