farmLifeKit
Make a cozy farming and life sim in any Zero world, multiplayer from the start.** Clear a plot, till the soil, plant seeds, water them every morning, watch them grow over the days and seasons, harvest, drop the harvest in the shipping bin, wake up to the money and spend it at the…
farmLifeKit
Make a cozy farming and life sim in any Zero world, multiplayer from the start. Clear a plot, till the soil, plant seeds, water them every morning, watch them grow over the days and seasons, harvest, drop the harvest in the shipping bin, wake up to the money and spend it at the village store on seeds and tool upgrades. End the day in bed (stay up too late and you pass out), read what you sold, check the calendar for festivals and villager birthdays, befriend the villagers, and work the same farm with a friend.
Version 1.0.9 (Farm.VERSION).
farmLifeKit holds only the farming-game glue. Everything else comes from published kits it installs with it:
| kit | what the farm uses it for |
|---|---|
| cropsKit 1.0.15 | plots, crops, watering, growth over days and seasons, saving plants, co-op plot rules, the shared bed vote, the geometry the farm's props are drawn with |
| economyKit 1.2.11 | coins, wallets that keep between sessions, the bank machine that pays the shipping bin, the store screen, shared farm accounts (brings inventoryKit 1.0.24, saveKit, menusKit, navUiKit) |
| toolUseKit 1.0.4 | holding a hoe, watering can, seed pouch, axe, pickaxe, scythe or hammer and using it on the tiles in front of you, tool tiers that cover a bigger area, the energy each use costs, the tool strip the farm places |
| friendshipKit 1.0.3 | eight villagers to befriend with chats and gifts (mira, bram, pip, finn, odette, juniper, wren, marlow), placed standing on the ground with their own models, their birthdays on the calendar |
| worldClockKit (via cropsKit) | the shared clock, day and night, seasons and weather |
| interactKit (via cropsKit) | "Press E" prompts on the bin, bed, calendar board and store |
| productionKit, buildPlaceKit (optional) | farm buildings players place themselves: beehive, chicken coop, farmers' market |
| forestKit (optional, not installed with the kit) | the woodland around the forest clearing layout: install forestKit and pass forest = asset.resolve("~forestKit.Forest", "component") to Farm.build; without it the clearing is ringed by cropsKit trees |
Quick start (5 minutes)
-
Install. Search ZeroMind for
farmLifeKitand install it (or install economyKit first if you add kits by hand: see Known limits). The kits above come with it. -
Build the farm. Open
scenes/main.scene/build.luauand put this at the top and insidecontent():local Farm = require("~farmLifeKit.api") function content() local farm = Farm.build({ layout = "meadow" }) -- keep your scene's player prototype and spawn; move the spawn to the farm: -- spawn.localPosition = farm.spawn endAny scene with a player works (the starter scene's
PlayerSetupsandSpawnsare fine). Save: a meadow with a fenced field full of weeds, stones and stumps, a cottage and bed, a shipping bin, a calendar board and the village store appear. -
Press Play. You hold a hoe. Walk to the field and:
- clear: scythe the weeds, pickaxe the stones, axe the twigs and stumps, or break stones and stumps with the hammer (the mouse wheel, Q / F or the bumpers switch tools);
- till: hoe a grass tile (left click or C);
- plant: pick the carrot seeds on the item bar (key 1 to 8, d-pad left / right, or tap the slot) and press the plot's prompt (E), or sow a whole area with the seed pouch;
- water: watering can on the soil, once a day;
- sleep: walk to the bed and press E. Morning comes, the crop grows a stage;
- harvest: when it is ripe, scythe it (or press E on it);
- sell: pick the carrots on the item bar and press E at the shipping bin (the prompt and the item bar both name what will ship), then sleep. You wake to a summary of what sold and the coins in your wallet;
- spend: press E at the store for this season's seeds and tool upgrades.
That is the whole loop. Everything below is a setting.
Controls
One press does one thing. The item bar (the bag's 8 hotbar slots, drawn by the farm with the selected slot highlighted) picks what you hold, plant and ship; toolUseKit's strip holds the tools; interact is only interact.
| action | keyboard and mouse | gamepad | touch |
|---|---|---|---|
| move | WASD, mouse to look | left stick, right stick | left joystick, drag to look |
| use the held tool (hold to charge a bigger area) | left click or C | right trigger | USE button |
| switch tool | mouse wheel, Q / F | bumpers | tap the tool strip |
| pick an item (what you plant and ship) | 1 to 8 | d-pad left / right | tap a slot on the item bar |
| interact (bin, bed, store, calendar board, plots; hold for the bed) | E | west face button (X) | Interact button, or tap the hint on the item bar |
| talk to a villager | E | west face button | Talk |
| give a gift | R | d-pad up | Gift |
| friends panel | O | d-pad down | Friends button |
| calendar | K, or E at the calendar board | Select | Cal button on the date strip |
| start the day / close a farm screen | Enter or Space / Escape | south / east | the buttons on screen |
| build mode (in the build zone) | B | per buildPlaceKit | Build button |
How the clashes were resolved (1.0.8): the farm's farmItems input map owns 1-8 and the d-pad's left and right, and while it is live it stands inventoryKit's own map down (its hotbar keys, its bumper slot cycling, Tab / I, F, G and its chest E). toolUseKit 1.0.4 gets numberKeys = false and binds nothing on E; with toolUseKit 1.0.3 the farm puts the held tool back after a digit or E press. friendshipKit gets gift R, Friends O, pad gift d-pad up and pad Friends d-pad down. The farm itself binds no E.
Phone layout
The farm decides where every piece goes, as a pure function of the screen (farmLifeKit.layout: width and height in points, the safe-area margins, touch or not, the engine's touch buttons and whether its overflow menu is open), and tells the kits: toolUseKit's hudPosition (1.0.4), friendshipKit's buttonPosition (1.0.2), buildPlaceKit's touch anchor (when it takes one).
-
Desktop: Friends and the date strip top right, tools bottom centre, the item bar above them, the farm's prompt above that. The tool strip is measured with toolUseKit's own hud layout (its held-tool name, such as "Basic Scythe", and its energy meter included), so the item bar and its caption sit above the tool name at every size.
-
Phone held sideways (about 693 by 390 points): tools and the item bar top left, Friends and the date strip top right, Build left of the engine's buttons. When the engine's overflow menu opens, the item bar drops to the bottom left and the prompt moves under the date strip; on a touch screen the item bar's hint ("Tap: Ship 4 Carrot") is itself an interact button, so shipping and sleeping need no trip into that menu.
-
Phone held upright (390 by 844 points): the date strip top left, Friends top right, the item bar under them, tools above the engine's button column.
-
The engine's own buttons, as drawn: the layout reads zinput's live touch layout. A "corner" button (zinput's Menu, top right) pushes Friends below it through friendshipKit's top inset; when no spot clears the engine's buttons, the item bar drops its caption line before covering one; Build always stays on screen.
Screenshots: showcase/phone/ in the Harvest Hollow world. The tests check both phone shapes for pieces inside the safe area and off each other and the engine's buttons, and that toolUseKit's tool name never touches the item bar or its caption on a 1280 x 720 and a 1920 x 1080 desktop and on both phone shapes.
One setting, many styles
Every choice is a field on FarmLife and an option of Farm.build:
| option | choices | default |
|---|---|---|
layout | meadow, riverside, hillside (three terraces), forestClearing (inside forestKit's woodland), island, greenhouse | meadow |
look (crops and props) | cozy (cartoon with ink outline), pixel (voxels), natural | cozy |
rules | relaxed, classic, hard | classic |
moneyMode | separate (each player their own coins), shared (one farm purse) | separate |
binStyle | crate, wicker, mailbox, pixel, scifi, barrel, trough (every bin whose own style is empty follows it live) | crate |
summaryStyle | ledger, pixel, painted, receipt | ledger |
calendarStyle | paper, pixel, painted, wooden, chalkboard | paper |
hudStyle (date strip) | cozy, pixel, painted, minimal | cozy |
toolStyle | cartoon, pixel, painted, realistic, scifi (tiers Basic, Copper, Steel, Gold, Iridium) | cartoon |
friendDisplay | hearts, stars, bar, pixelHearts, flowers, leaves, numeric, ring | hearts |
friendLook | cozy, pixel, painted, minimal | cozy |
startTools | toolUseKit ids, comma separated (a player missing one is given it) | hoe,wateringCan,seedPouch,axe,pickaxe,scythe,hammer |
itemBar | true, false (a game draws its own) | true |
farmKey | the name saves are kept under | farm |
A bin follows the farm when its own style is empty: Farm.build leaves it empty, and Farm.bin(pos, { style = "barrel" }) pins one bin to a look.
Other Farm.build options: seed (debris layout), startItems ("carrotSeeds:15,poppySeeds:5"), dayLengthMinutes, daysPerSeason, store = false, buildings = false, storeLook, buildStyle (rustic or scifi).
Combined art styles: put a styleKit look on the scene and it stacks on top of the farm's look. The showcase uses toonBlocks' saturdayMorning; pictureBook or watercolor from watercolorBlocks give a painted farm, and look = "pixel" with binStyle = "pixel", summaryStyle = "pixel", calendarStyle = "pixel", hudStyle = "pixel", toolStyle = "pixel" and friendDisplay = "pixelHearts" a pixel art one.
Rule presets
| relaxed | classic | hard | |
|---|---|---|---|
| days per season | 28 | 28 | 28 |
| starting coins | 800 | 500 | 200 |
| ship prices | x1.25 | x1 | x0.8 |
| pass out at | 3 AM, no money lost | 2 AM, 10% lost | 1 AM, 25% lost |
| energy | large pool | normal | small pool |
| debris on the field | light | normal | heavy |
Farm.defineRules("mine", { ... }) adds a preset; Farm.setRuleOverrides({ startMoney = 1000 }) changes single values.
How the day works
- Morning: the clock starts at the wake hour. Energy is full (only partly after passing out).
- Day: tools cost energy. A tool use that hits nothing gives the energy back.
- Night: sleep in the bed. Alone you sleep at once; with friends the night passes once everyone is in bed (cropsKit's sleep vote).
- Too late: at the rules' pass-out hour you collapse, are carried to the bed and lose a share of your coins (none on relaxed).
- Overnight: the bank machine pays every shipping bin at its item prices (a festival with a ship bonus adds to it), the bins empty, and each player wakes to the end of day summary of what they sold.
- Seasons matter: crops grow only in their seasons (cropsKit), the store sells only this season's seeds, and a season change is announced.
- Calendar: the season, today, eight festivals (egg hunt, flower dance, summer luau, lantern night, harvest fair, spirits' eve, ice festival, star night) and every villager birthday. Add festivals as
farmLifeKit.festivaldata assets or withFarm.defineFestival.
Co-op and saving
- A second player who joins plays on the same farm: same fields, crops, bins and clock, and either can till, water, harvest and ship. The farm's synced entities are decided by one machine, so two players never both win the same tile.
moneyMode = "shared": one farm purse every player spends from and earns into."separate": each player keeps their own wallet and is paid for what they shipped.Farm.setMoneyModeswitches it live.- Everything stays exactly as left after everyone leaves: fields and debris, tilled soil and plants (cropsKit), bin contents, coins (economyKit), tool tiers and energy (toolUseKit), friendship (friendshipKit), placed buildings (buildPlaceKit) and the date: day, season, year and the hour.
- The date is kept by the farm itself (world data under
farmLifeKit/<farmKey>/clock, every 2 seconds) as well as by worldClockKit. A play session can start from the clock records the editor last published, and then worldClockKit's own restore never runs (the calendar came back on Spring 1); the farm puts the clock back on the later of the two saves on the machine that decides the clock, before the payout or the morning run. Any game usingFarm.buildgets this.Farm.core.resetDate()starts over on day 1. - The bin pays when a day really ends. Loading the world pays nothing: the payout settles only when today is later than the last paid day. A clock that went back behind it (a reset) re-anchors the day without paying, and the bin keeps its contents for the next night.
Farm buildings
Farm.build puts a build zone beside the first field. Press B inside it to place a beehive (honey), a chicken coop (eggs) or a farmers' market (sells honey and eggs for coins). They are productionKit buildings: they keep working while nobody plays and pay the player who built them. Farm.buildings.define(...) adds your own; see the example guide.
API
local Farm = require("~farmLifeKit.api")
- Building a farm (in
content()):Farm.build(opts), or the parts one by one:Farm.life(opts),Farm.field(pos, opts),Farm.bin(pos, opts),Farm.bed(pos, opts),Farm.calendarBoard(pos, opts),Farm.store(pos, opts),Farm.villager(id, pos, { model, yaw }). - Playing:
Farm.on(event, fn)(events: tilled, cleared, shipped, settled, summary, passedOut, woke, festival, birthday, seasonChanged, upgraded, moneyModeChanged),Farm.settings(),Farm.currentRules(),Farm.setRuleOverrides(t),Farm.setMoneyMode(mode),Farm.coins(),Farm.setPrice(item, coins),Farm.settleNow(),Farm.openCalendar(). - Layout:
require("~farmLifeKit.layout").compute({ W, H, safe, touch })answers where every piece goes;Layout.problems(lay, W, H, safe)lists overlaps. - Extending:
Farm.defineFestival,Farm.defineRules,Farm.defineLayout,Farm.defineProp(a new bin look is a prop namedbin.<style>),Farm.defineTool(what a new tool does on a tile),Farm.catalogue()(every choice above). - Components:
FarmLife,FarmField,ShippingBin,FarmBed,CalendarBoard,FarmStore,FarmProp,FarmHud(spawned per player),FarmExhibit(a gallery station). Each has its own README. - Icons: every item the farm sells shows a bright icon from the kit's
icons/folder (cropsKit's own are dark renders on black, which read as black squares in economyKit's shop).iconBakerbakes them;farmLifeKit.iconsputs them on the items at runtime. - Prices: an item ships for its inventoryKit
valuetimes the rules' price scale. Add a crop's harvest item with avalueand it sells. Nothing ships for more than the store sells it for: an item the farm store sells (every crop's seeds in cropsKit's catalog, other kits' crops too, and any entry the store defines) ships for at most half its store unit price, rounded down (Prices.STORE_SHARE), under every rules preset; seeds that cost under 2 coins a seed ship for nothing and the bin refuses them. Harvests keep their own price.Prices.storeUnit(item, rules)answers the unit price the cap is taken from.
Gallery
farmLifeKit.farmGallery is a scene inside the package to walk around, every style side by side with its name floating over it: the seven bin looks in a row, the three crop and prop looks (a planted plot, a cottage, a bin and a fence each), the six layouts as named signs (walk up for the description), and screen stations: the four date strips, the five calendars and the four end of day summaries, each set side by side, toolUseKit's tool styles and friendshipKit's friendship displays (tap to switch, with Mira beside the board to see them on). The calendars and summaries are the real screens drawn small by Screens.thumbnail(tree, kind, scale), which lays a screen out at full size and scales it with a CSS transform; a "Full size" tab opens one style over the station and a second tap closes it. It runs on its own farm key, so it never touches a farm's saves.
Workflow: make a cozy farming game
makeCozyFarmingGame (in workflows/) walks a creator from an empty world to a playable farm: survey, install farmLifeKit, build the farm with Farm.build, place villagers, play the whole loop with simulated input, check keyboard, gamepad, touch and both phone shapes, check saving, publish. Start it with zero workflow start --name makeCozyFarmingGame (args: pitch, layout, look, coop); each step arrives as a request: take it with zero workflow next <your name> (the prompt is in the file it names), do it, and hand back its answer with zero workflow answer <request> <value> in the shape the request's schema states (zero workflow fail <request> <why> for a step you are not doing). In a world that already holds a farm, point the Survey answer at a scratch scene (zero scene create scenes/scratch player) so the build leaves your scene alone. A full run in the Harvest Hollow world (island, cozy, co-op) built, placed all eight villagers, played the loop with real input (scythe, pickaxe, hoe, plant with E, water, sleep holding E, harvest, ship with E, paid overnight, bought seeds at the store), passed the device and saving checks, and fixed two island layout defects it found.
Tests
farmLifeKitTests covers the loop (tools on the field, plant, water, grow, harvest, price), store prices (no store item ships for as much as its store unit price under relaxed, classic and hard), the payout (once at day end, never at load, not when the clock goes back), shared and separate money, the date restore, the bin following the farm, the style counts, the bindings, the phone layout at 693 x 390 and 390 x 844, and toolUseKit's tool name clear of the item bar caption on desktop and phones. Run it with tools.use("tests", "run", { suite = "farmLifeKitTests" }).
Guides
Inside the package, readable in the Docs panel, with man or the guides tool:
- How to make a farming game (
guides/how-to-make-a-farming-game): the loop, the shipping bin and the shop, the calendar, co-op, saving, and how the kits fit. - Example: add a new crop and a new farm building (
guides/example-add-a-new-crop-and-a-farm-building): a strawberry crop that sells, and a preserves shed that turns honey into jam.
Known limits
- Install economyKit before cropsKit when you add them yourself (the other order is refused because menusKit records two controlsKit releases). Installing farmLifeKit brings them in an order that works.
- cropsKit 1.0.11 and economyKit 1.2.10 ship different inventoryKit releases. farmLifeKit points cropsKit at economyKit's inventory so each player has one bag (a fix is offered upstream).
- The farm's props are drawn at runtime by
FarmProp, because a scene build cannot create meshes. - Frames are heavy with the forest layout and a toon look on small machines;
meadowis the lightest layout.
Changes
- 1.0.9: phone layout checked live on a sideways phone (touch and gamepad) and an upright one. The two-line date strip sits beside the item bar on a sideways phone (clear of the engine's large USE button) and is also used on any short non-touch screen; the touch Build button is placed by the farm on every screen (bottom left when played with a gamepad, so it never sits on the tool strip) and measured from the top safe margin, so it stays above an upright phone's home bar.
- 1.0.8: on a phone held sideways the date strip is two short lines (date and time, then coins) and the strip itself opens the calendar, so it fits between the engine's Menu and USE buttons and beside its open menu. needs toolUseKit 1.0.4 and friendshipKit 1.0.3 (cropsKit 1.0.15, economyKit 1.2.11, one inventoryKit 1.0.24). Seeds no longer sell for a profit: an item the store sells ships for at most half its store unit price. The item bar sits above toolUseKit's held-tool name on every screen (the strip is measured with toolUseKit's own layout).
Farm.villagerhands placement to friendshipKit, so villagers stand on the ground (a centred model put straight on an entity sank to the waist); the showcase places all eight. The gallery shows every calendar and summary style side by side. The island layout no longer throws the player off at spawn. An item bar on every device (keys 1-8, gamepad d-pad left / right, a tap) picks what you plant and ship, and inventoryKit's own keys stand down while the farm runs, so one press does one thing (1-5 no longer switch tools, bumpers no longer move the hotbar, E only interacts). The farm lays out its date strip, item bar and prompt, toolUseKit's strip, friendshipKit's button and buildPlaceKit's Build button for desktop and for phones held sideways or upright, and keeps clear of the engine's touch buttons and its open overflow menu; the item bar's hint is a tap-to-interact button on touch. The date (day, season, year, hour) survives a restart, and the bin pays only when a day really ends (never at load; a clock that went back keeps the bin for the next night). Changing FarmLife's binStyle restyles every bin that follows the farm, in the editor too. A fifth calendar style (chalkboard). Bright item icons for the store and the item bar, including upgrade tickets, fiber and stone. The seed pouch sows the picked seeds and the hammer breaks stones and stumps. A style gallery scene, the makeCozyFarmingGame workflow and a test suite. - 1.0.7: needs friendshipKit 1.0.1, whose Friends button keeps inside a phone's notch margins. On a narrow screen the date strip stacks under the Friends button (beside it on a wide one, measured from the button as drawn), and the farm keeps its wallet display and cozy or pixel look on economyKit when economyKit comes back on its defaults (it showed the corner counter and the sci-fi shop look).
- 1.0.6: phone layout pass. The coins now show in the date strip under the clock (economyKit keeps its rising "+10" popups instead of a corner counter, which sat on the tool strip), the date strip steps left of friendshipKit's widget instead of covering it, and a clock that went back with nothing in the bin no longer posts an empty summary.
- 1.0.5: needs toolUseKit 1.0.3, where the gamepad's X is only interact and the right trigger uses the tool (before, one X press at the bin both swung the tool and shipped).
- 1.0.4: the overnight payout runs on any change of day, so a farm whose clock came back behind its last paid day (a clock reset, or a cleared clock save) still pays the shipping bin; a summary that arrives a moment after waking opens on screen too.
- 1.0.3: interact works with every input in worlds where interactKit runs two releases (its prompt HUD then knows none of the farm's devices): the farm finds the bin, bed, store, calendar board or plot you stand at, shows the prompt itself and sends the use on the same interact button (E, pad X, touch Interact); it stays out of the way when interactKit sees them. The farm's network listeners and interact subscription also come back after a live code reload.
- 1.0.2: forestKit is no longer pulled in by the kit (its atmosphere code runs two worldClockKit releases, which a fresh install refuses); pass its Forest component with the
forestoption instead. - 1.0.1: co-op fix: when another inventoryKit release owns the shared host entity, the farm ticks its own bag, so a second player's bag always becomes ready.
- 1.0.0: first release.
Scoped to this part · feeds back into the world's score.