# RegrowGallery
A local demo of every regrowKit preset side by side: one small berry bush post per preset (quick, normal, slow, hourly, daily, never), each with a Regrowing component in a spent look (shrink, fade or hide) and labels showing its preset, timer and live charges. Press R (the `key` field) or call `takeAll()` to take a charge from every post and watch them use up and grow back. Put it on any plain entity; it spawns only local, temporary parts, so it is safe in any scene.
# NeedsGallery
See every survivalNeedsKit preset on your own HUD. A panel on the right of the screen steps the live needs HUD through all six layouts (corner bars, ring cluster, icon pips, body silhouette, minimal lines, hotbar strip) and all eight themes (sci-fi, fantasy, cartoon, pixel, minimal, realistic, horror, cozy) with its buttons, the `[` `]` and `-` `=` keys, or an automatic tour; it lists the six rule presets and five climates (click one to apply it) and the eighteen foods and drinks. Put it on any plain entity in a scene whose player body has a SurvivalNeeds. Each step is the same single call a game makes: `Needs.setup({ layout = "ring", theme = "pixel" })`. Local to each player.
# DropGallery
Every deathDropKit style in every look, side by side and labelled: one row per style (gravestone, loot bag, backpack, spirit orb, scattered items, washed-up crate, skeleton pile), its three looks along the row, the default look first. A sign at the head lists the five rules and four markers. Put it on any plain entity; it needs no other component and spawns only local, temporary parts, so it is safe in any scene. Pick what you saw with one change: `Drops.setup({ style = "crate", look = "shipwreck" })`.
# ModePreview
Change ONE setting, the survival mode, and watch everything it carries change together. A panel on the right of the screen has a button per mode (castaway, cozy, hardcore, creative); each click is the single call a game makes, `Castaway.setup({ mode = "cozy" })`. That sets the needs HUD layout and theme (survivalNeedsKit), the death drop style, look and marker (deathDropKit) and the night's threat set (nightCreaturesKit) from the mode, and the stand in the world shows the result: the death drop as a player would leave it, with its marker, and the threat set's creatures in a row. Put it on any plain entity in a scene whose player has a SurvivalNeeds; it needs no sibling component. Local to each player; everything it spawns is temporary.
# SurvivalNeeds
One player's eight meters. Put it on the PlayerPrototype's body so every joining player gets their own. Only that player's engine changes the values (synced to everyone). Each frame it drains needs by the in-game hours worldClockKit's clock moved, warms or chills toward the felt temperature, soaks in the sea and rain, spends stamina when sprinting, drains oxygen under water, hurts the body through SecondWind when a meter is critical and heals it when all are healthy, refills after a SecondWind respawn, and draws the HUD. Needs SecondWind on the same body for damage and healing.
# RecipeGallery
Put it on any entity to see the recipeKit craft menu in every theme and layout. On each machine (local only) it opens the menu, shows a button panel to switch theme and layout, and with `cycle` on steps through the themes every `seconds`. When no recipes exist it loads the three ready packs (`loadPacks`). Needs no sibling component.
# CreatureGallery
Every nightCreaturesKit creature in both of its looks, standing in a labelled lineup and slowly turning: crab swarm, wolf pack, shadow stalker, bats, drowned sailor, jungle cat, giant spider and will-o'-the-wisp, each with its health, speed, group size and fear of fire. A sign lists the four threat sets (and which creatures each brings) and the three densities. Put it on any plain entity; it needs no other component and spawns only local, temporary parts. Switch the whole night with one change: `Creatures.setup({ threat = "haunted" })`.
# CastawayGallery
Every survivalCraftKit fire and shelter built for real out of buildPlaceKit pieces in a labelled row: campfire, torch post, signal fire, stone hearth and torch ring; lean-to, palm hut, tent, driftwood cabin and beach pavilion; palm bed, bedroll, hammock and raised cot, each with what it costs and how far it warms, lights or covers. Signs beside the row describe the four modes (castaway, cozy, hardcore, creative) and three island starts (cove, volcano, atoll). Put it on a synced entity in a gallery scene of its own: the host builds the pieces, every player sees them, and buildPlaceKit's saving is turned off for that session so gallery pieces never reach a player's saved camp. Uses `Castaway.buildAt`, the same builder the craft menu uses.
# GatherGallery
Every gatherKit resource as a working gather spot in one row, labelled with its name, what one pick gives (with chances), its tool, how many picks it holds and its regrow preset. Each spot is a real GatherSpot (prop, regrowKit Regrowing and interactKit prompt), so in play you can walk the row and gather from each one. Put it on any plain entity; it needs no other component and spawns only local, temporary parts, so it is safe in any scene. Fields: `spacing`, `labels`, `prompts`.
# needs
The public surface of survivalNeedsKit: `setup` picks the rule preset, climate, HUD layout and theme by name; `get`, `add`, `spend` and `consume` read and change the local player's meters; `heatAt`, `lightAt`, `fires`, `shelterAt` and `waterAt` answer questions about the world's HeatSource, Shelter and WaterSource components; `on` listens to `low`, `critical`, `recovered`, `ate` and `drank`. Called by game scripts, by the kit's components and by other kits (night creatures read `lightAt`, the castaway kit reads `fires`).
# castaway
survivalCraftKit's wiring. `setup` configures inventoryKit, survivalNeedsKit, deathDropKit, nightCreaturesKit, buildPlaceKit, craftingKit and controlsKit for a mode. `craft`, `placeBlueprint` and `gather` are the castaway actions (paying from the shared bag, placing buildPlaceKit pieces under a permit the build hook checks). `startObjectives` and `objectiveEvent` drive navUiKit's objective list; `saved` and `save` keep progress in saveKit. Called by the survivalCraftKit components and by game scripts.
# regrowKit
Things that get used up and grow back, for any multiplayer Zero game: berry bushes, trees, ore rocks, fishing spots and loot crates. Answers "how do I make bushes and trees grow back after harvesting", respawning resources, regrowing resource nodes and harvestable nodes that refill on a timer. Put a `Regrowing` component on a synced entity, pick a regrow preset and a spent look, and take charges from scripts; the entity's owner decides every take, so two players never get the same charge.
Version 1.0.2. New in 1.0.2: released from the Castaway Isle main line together with the other survival kits, on the current engine library; no behaviour change.
```lua
local Regrow = require("regrowKit.regrow")
local bush = entity.spawn("berryBush", { position = { 4, 0, 2 } })
bush:setSynced(true)
-- children of the bush are its leaves and berries (the part that shrinks)
bush.component.add(asset.resolve("regrowKit.Regrowing", "component"),
{ maxCharges = 3, regrow = "normal", spentLook = "shrink", visual = "berries" })
Regrow.take(bush, function(granted)
if granted then print("you picked a berry") else print("nothing left, come back later") end
end)
Regrow.on("regrown", function(id) print("bush " .. tostring(id) .. " is full again") end)
```
## Styles and options
Regrow presets (`regrow` field, or `Regrow.secondsFor(id)`):
| Preset | Grows back in | Good for |
| --- | --- | --- |
| `quick` | 30 s | grass, pebbles, sticks |
| `normal` | 90 s | berry bushes, small plants (the default) |
| `slow` | 300 s | trees, ore rocks |
| `hourly` | 1 in-game hour on worldClockKit, 150 s without it | fishing spots |
| `daily` | 1 in-game day on worldClockKit, 600 s without it | loot crates, rare nodes |
| `never` | does not come back | one-time loot |
`regrowSeconds` > 0 overrides the preset with real seconds. Add your own with `Regrow.define("seasonal", { label = "Seasonal", seconds = 1200 })` or `{ gameHours = 72, seconds = 1800 }` to follow the in-game clock.
Spent looks (`spentLook` field), applied to every child entity, or only the child named by `visual`:
| Look | While spent | When it grows back |
| --- | --- | --- |
| `shrink` | children scaled to 25% (default) | grow back smoothly over 1.5 s |
| `fade` | children scaled to 60% | grow back smoothly over 1.5 s |
| `hide` | children hidden | shown again |
| `none` | unchanged | unchanged |
Other fields: `charges` (-1 fills to `maxCharges` on start; synced, written by the owner), `maxCharges` (5), `readyAt` (synced `os.time()` when it grows back, 0 while not spent).
To see every preset at once, add the `RegrowGallery` component to a plain entity and press R.
## API
Module `require("regrowKit.regrow")`:
- `M.VERSION: string` is `"1.0.2"`; `M.CHANNEL` is `"regrowKit"`; `M.EVENTS` lists the event names.
- `M.PRESETS: { [string]: { label: string, seconds: number, gameHours: number?, description: string } }` and `M.PRESET_ORDER: { string }`.
- `M.define(id: string, def: { label?, seconds: number, gameHours?, description? }) -> preset` adds or replaces a preset.
- `M.secondsFor(presetOrSeconds: string | number) -> number` real seconds to grow back (-1 is never); reads worldClockKit's day length when the preset has `gameHours`, falling back to `seconds`. An unknown id answers `normal`.
- `M.on(event: string, fn) -> () -> ()` subscribes; returns unsubscribe. Events: `taken(entityId, peer, chargesLeft)`, `spent(entityId)`, `regrown(entityId)`, `refused(entityId, peer)`. They fire on the owner's machine.
- `M.take(e, fn: ((granted: boolean) -> ())?)` asks the entity's Regrowing owner for one charge for the local player; `fn` runs on this machine. When this machine owns the entity (or the owner reads 0), it decides at once and calls `fn` right away. An entity without Regrowing answers `false`.
- `M.state(e) -> { charges: number, max: number, readyAt: number, spent: boolean }?` or nil without Regrowing.
- `M._emit(event, ...)` fires an event (used by the component).
Component `Regrowing` (`asset.resolve("regrowKit.Regrowing", "component")`), public methods on `e.component.get(ref)`:
- `public:take(peer: number) -> boolean` owner only: spends a charge if any, sets `readyAt` when it reaches 0, emits `taken` and `spent`, or `refused`.
- `public:refill()` owner only: fills to `maxCharges`, clears `readyAt`, grows the look back, emits `regrown` if it was spent.
- `public:describe() -> { id, charges, max, readyAt, spent, regrow, seconds, spentLook, look, hidden, growing }`.
Component `RegrowGallery`: fields `spacing`, `charges`, `key` (`"KeyR"`), `labels`; method `public:takeAll()`.
## What it installs
Installing regrowKit brings these packages, each from its own world, at the versions it was built and tested with:
| Package | Version |
|---|---|
## Multiplayer
Put `Regrowing` on a synced entity. `charges` and `readyAt` are synced fields written only by the entity's owner (`entity:owner()`, with owner 0 treated as local), and the owner's `update` refills the node when `os.time()` reaches `readyAt`. A take from another machine travels on the multiplayer channel `regrowKit` as `("take", entityId, peer)`; the owner spends the charge and replies `("grant", entityId, peer, granted)`, which runs the asker's callback. Because only the owner decides, two players tapping the same bush never both get the last berry. Every peer draws the spent look from the synced charges, so everyone sees the same bush. Give the item only inside the `granted` callback.
## Tests
`regrowKit.testSuite` has 15 tests covering presets, `secondsFor`, `define`, spending and refilling, local `take`, events and the spent looks. Run it with `asset.resolve("regrowKit", "testSuite"):run()`.
## Guides
- `how-do-i-make-resources-grow-back-after-players-harvest-them`: the how-to.
- `example-berry-bushes-that-regrow-in-a-survival-game`: a worked example.
# survivalNeedsKit
**Add hunger, thirst, staying warm, rest, stamina, getting soaked, sanity and oxygen to any multiplayer Zero game.** For creators asking "how do I add hunger and thirst to my game", "how do I make players get cold at night" or "how do I make a survival game with food and water". Every player has their own meters on their own body, statuses like Well Fed or Freezing change how they play, and you pick the rules, the climate, the HUD layout and the theme by name.
Version 1.0.13. New in 1.0.13: a burning fire no longer breaks heatSignatures. The fire's own heat record gave heatSignatures `active = true` where it reads a temperature, so heatSignatures' whole tick failed every frame while a fire burned; it gives 420 C now, the same as the fire's built piece. New in 1.0.12: released from the Castaway Isle main line together with the other survival kits, on the current engine library; no behaviour change. New in 1.0.11: status chips (Shivering, Soaked, Well Fed and the rest) stand side by side with room for their names; before, an emoji at the head of each chip's text made it too narrow and the names ran over each other. New in 1.0.10: a fire that went out is cold the moment it dies. heatSignatures cools the stones and sand round a fire over minutes, so what it reads beside a dead fire no longer counts as warmth unless something there is still burning (before, a burnt-out fire kept a player warming for about two minutes). New in 1.0.9: a fire that has gone out is cold everywhere. heatSignatures warmth only counts with something hot in reach, so sun-warmed sand no longer warms you, and a HeatSource's new `piece` field makes the built thing it belongs to (a campfire piece) read hot only while it burns. A fire that runs out goes cold: its warmth and light stop at once, and with heatSignatures installed its heat record goes too (a dead fire no longer warms anyone). Rain comes from worldClockKit's live weather, so a shower soaks you outside, and a Shelter keeps you dry and holds most of the night's cold out (`insulation`). All six HUD layouts are now barsKit bars. Fires can always be brought back: feed one wood, palm leaves, fiber or a coconut, or light it with a torch or a flint once it is out (`feedFire`, `lightFire`, `HeatSource:relight`). Each player's meters are saved with **saveKit** when it is installed, so hunger, thirst and the rest come back as they were left after leaving play, rejoining or restarting the world. Built on **SecondWind** (empty meters hurt, healthy ones heal), **barsKit** (all six HUD layouts), **inventoryKit** (food and drink are bag items) and **worldClockKit** (needs follow the shared day and night). Works with **tropicalKit**'s island for the sea (wading soaks you, diving uses oxygen) and with **abilitiesKit** for status effects.
## Quick start
In your scene's `build.luau`, after the default player setup (`body` is the player's body), and in its `entrypoint.luau`:
```luau
body.component.add(asset.resolve("survivalNeedsKit.SurvivalNeeds", "component"), {})
local fire = entity.spawnSynced("Campfire", { position = { 4, 0, 6 } })
fire.component.add(asset.resolve("survivalNeedsKit.HeatSource", "component"), { radius = 6, warmth = 30 })
local spring = entity.spawn("Spring", { position = { -6, 0, 3 } })
spring.component.add(asset.resolve("survivalNeedsKit.WaterSource", "component"), { label = "Spring" })
-- entrypoint.luau
local Needs = require("~survivalNeedsKit.needs")
function onLoad()
Needs.setup({ rules = "castaway", climate = "tropical", layout = "corners", theme = "realistic" })
end
```
Your scene needs a worldClockKit WorldClock: needs drain by in-game hours, so without a clock they hold still. Press Play: your meters sit on the left edge, drain with the clock, and the spring and fire bring them back.
## Styles and choices
| Setting | Values |
|---|---|
| `rules` | `off` (creative), `cozy`, `standard`, `castaway`, `hardcore`, `horror` |
| `climate` | `tropical`, `temperate`, `desert`, `arctic`, `swamp` |
| `layout` | `corners`, `ring`, `pips`, `silhouette`, `minimal`, `hotbarStrip`: every one is barsKit bars (the theme's look, then barsKit's `ring`, `pips`, vertical `gauge`, `line` and the theme's look again); without barsKit the kit draws its own panels |
| `theme` | `scifi`, `fantasy`, `cartoon`, `pixel`, `minimal`, `realistic`, `horror`, `cozy` |
| Rules | What runs |
|---|---|
| `off` | No needs at all: build and explore freely. |
| `cozy` | Hunger, thirst, warmth, rest, gentle and slow. |
| `standard` | Adds stamina and getting soaked. |
| `castaway` | Adds oxygen; thirst bites and the sea soaks you. |
| `hardcore` | All eight, fast, no natural healing. |
| `horror` | Sanity drains in the dark and away from fire. |
| Climate | Feel |
|---|---|
| `tropical` | Hot days, cool damp nights, sudden showers. |
| `temperate` | Mild days and properly cold nights. |
| `desert` | Scorching sun, freezing nights, thirst doubles at noon. |
| `arctic` | Cold all day, deadly at night: a fire is life. |
| `swamp` | Warm, wet and never quite dry. |
### The needs
- **Hunger, thirst, rest, sanity** drain by the in-game hour, so any day length works.
- **Warmth** moves toward how warm it feels: the climate's day and night air, plus every burning HeatSource nearby, minus a chill when you are soaked. Under a Shelter the roof keeps out `insulation` (0.6 by default) of the night's cold and adds its own `warmth` (6), so a lean-to at night feels far warmer than the open beach (about 62 against 34 on the tropical island).
- **Wetness** rises in the sea and in rain outside a shelter (worldClockKit's blended weather: steady rain soaks you in a few seconds), and dries by the fire and in the sun.
- **Stamina** drains while sprinting and returns faster when fed and rested.
- **Oxygen** drains while your head is under the sea and comes back fast in the air.
A meter at its critical line hurts through SecondWind (`label = "Exposure"`); all meters healthy heal slowly. After a SecondWind respawn the meters refill to `respawnFill` percent.
### Statuses
Seven statuses come from what the meters add up to. They show as small chips on every HUD layout, fire the `statusOn` and `statusOff` events, and with abilitiesKit installed each becomes a real abilitiesKit effect on the body called `survival_<id>`.
| Status | Effect |
|---|---|
| `wellFed` (bonus) | Health comes back slowly and stamina refills 30% faster. |
| `starving` | Your swings deal 30% less damage. |
| `parched` | 15% slower, stamina refills at half speed. |
| `shivering` | 10% slower and you jump lower. |
| `freezing` | 35% slower and you lose health until you warm up. |
| `soaked` | 10% slower and you take 15% more damage. |
| `exhausted` | 25% slower and stamina barely refills. |
### Food and drink
Eighteen inventoryKit items with `useEffect = "event"`: coconut, wild berries, banana, mango, raw fish, cooked fish, crab meat, grilled crab, seaweed, fresh water, coconut water, herbal tea, fish stew, roasted root, jerky, honeycomb, ration bar, bitter coffee. Use one from the hotbar and it feeds the needs it lists. Add your own with `Needs.defineFood`.
## API
### needs module
`local Needs = require("~survivalNeedsKit.needs")`
- `setup(opts)`: pick `rules`, `climate`, `layout`, `theme` by name (any subset); call on every peer, changes apply live. `persist` (default true) saves each player's meters with saveKit; `persist = false` starts every session from the start values.
- `persists()`: whether the meters are saved (`persist` is on and saveKit is installed).
- `savedState()`: the local player's saved meters, `{ v = 1, needs = { hunger = 72.4, ... } }`, or nil when nothing is saved yet, saveKit is missing or the save has not loaded.
- `config()`: a copy of the current settings.
- Fires: `fires({ includeOut = true })` lists every HeatSource, burning or out (without it, only burning ones); `fireNear(x, z, range?)` is the nearest one in reach. `feedFire(fire, item?)` puts one fuel item from the local player's bag on it (`FUEL`: wood 120 s, palm leaf 40, coconut 30, fiber 20; `defineFuel(item, seconds)`), which also lights it again when it was out. `lightFire(fire)` lights a fire that is out with a lighter from the bag (`LIGHTERS`: torch, flint; `defineLighter(item)`), burning on what fuel is left, or on `KINDLING` (45 s) when it burned out. `tendAction(fire)` says which of the two the local player can do there, with prompt words. On the component, from any peer: `HeatSource:addFuel(seconds)` and `HeatSource:relight(kindling?)`.
- `rules()`: the current rule preset table.
- `climate()`: the current climate table.
- `active(need)`: whether a need runs under the current rules.
- `activeNeeds()`: the needs that run, in display order.
- `catalogue()`: every preset, climate, layout, theme, need and food, for menus and agents.
- `on(event, fn)`: listen to an event; returns a function that stops listening. Events: `changed`, `low`, `critical`, `recovered`, `ate`, `drank`, `setup`, `statusOn`, `statusOff`.
- `defineFood(id, def)`: add a food or drink: `{ name, gives = { hunger = 20 }, hp?, rarity? }`.
- `describeFood(id)`: a short text of what a food gives.
- `defineFoods()`: register every food as an inventoryKit item (done for you).
- `consume(foodId)`: apply a food's effect to the local player.
- `get(need)`: the local player's value for a need (0..100), or nil before their body is ready.
- `state()`: every need of the local player, `{ hunger = 72, ... }`.
- `add(need, n)`: change a need of the local player by n points (negative to drain).
- `spend(n)`: spend stamina; returns false when too tired.
- `of(body, need)`: read another player's need from their body (synced).
- `heatAt(x, y, z)`: heat at a point from every burning HeatSource.
- `lightAt(x, y, z)`: firelight at a point (0..1), for creatures that fear fire.
- `fires()`: every burning heat source, `{ { x, y, z, radius, lightRadius } }`.
- `shelterAt(x, y, z)`: the Shelter covering a point, or nil.
- `waterAt(x, y, z)`: the WaterSource within reach of a point, or nil.
- `darkness()`: 0 in full day, 1 at night.
- `rain()`: 0..1, how hard it is raining.
- `waterDepth(x, y, z)`: how far below the sea surface a point stands; 0 on land.
- `temperatureAt(x, y, z, wetness?)`: the felt temperature on the 0..100 comfort scale (50 is comfortable).
### statuses module
`local Statuses = require("survivalNeedsKit.statuses")`
- `define(id, def)`: add or replace a status: `{ label, icon, color, good?, when = { { need, op, value } }, description, effect, heal?, hurt? }`.
- `evaluate(values, running?)`: which statuses a set of need values gives, in order.
- `active()`: the local player's statuses right now.
- `has(id)`: whether the local player has a status.
- `STATUSES`, `STATUS_ORDER`: the status table and its display order.
### hud module
- `draw(c)`: draw the HUD for the local player's SurvivalNeeds component (done for you).
- `restyle()`: tear the HUD down so the next draw builds the chosen layout fresh.
- `teardown()`: remove the HUD.
### Components
**SurvivalNeeds**: one player's meters, on the PlayerPrototype body. Owner-written, synced.
- `hunger`, `thirst`, `warmth`, `rest`, `stamina`, `sanity`, `oxygen` (0..100), `wetness` (0..100, 0 is dry).
- `sprintSpeed` (5.2): ground speed above which the player spends stamina.
- `headHeight` (1.55): how deep the feet must be for the head to be under water.
- `respawnFill` (60): what each meter is set to after a respawn (percent).
- Methods: `value(need)`, `add(need, n)` (owner only), `refill(pct?)`.
**HeatSource**: a fire, torch or brazier on a synced entity.
- `radius` (6): how far the warmth reaches. `warmth` (30): comfort added at the centre.
- `lightRadius` (9): how far its light keeps night creatures away.
- `burning` (true), `fuel` (-1 burns for ever), `maxFuel` (600 seconds).
- `flame` (true), `flameSize` (1), `flameHeight` (0.25): the drawn flame and light.
- Methods: `heatAt(x, y, z)`, `lightAt(x, y, z)`, `describe()`, `addFuel(seconds)` (any peer, relights), `setBurning(on)`.
**Shelter**: inside its footprint rain stops, the roof keeps out `insulation` of the night's cold and adds `warmth`, and standing still restores rest.
- `radius` (2.5), `height` (3), `restBonus` (1).
- Method: `covers(x, y, z)`.
**WaterSource**: press E (pad X, or tap the prompt) to drink.
- `radius` (2.2), `label` ("Spring"), `amount` (35 thirst per drink), `cooldown` (1.2 s).
- `fill` (true): also give a Fresh Water to carry when the bag has room.
- `container` (""): item a player must carry to fill water, such as a flask; empty fills without one.
- `salty` (false): sea water makes you thirstier instead.
- Methods: `reaches(x, y, z)`, `drink()`, `prompt()`.
**NeedsGallery**: a panel to try every layout, theme, rule preset and climate.
- `tour` (true), `tourSeconds` (3), `open` (true).
## Works with heatSignatures
When heatSignatures is installed, every burning HeatSource also registers as a fire in heatSignatures (so a thermal look draws it) and is taken out again the moment it goes out, so a dead fire reads cold there too. The fire's owner gives the scene a heatSignatures climate that matches the needs climate if it has none, and `Needs.heatAt` reads heatSignatures' temperature (`Heat.at`, `HEAT_PER_DEGREE` points per degree above the air) and takes the larger of that and the fire's own falloff. Anything heatSignatures knows to be hot then warms a player too, so a fire drawn by another kit (a buildPlaceKit campfire piece) has to go cold there as well: survivalCraftKit puts the piece out with `Build.setLit` when its HeatSource dies. Without heatSignatures the fires' own falloff is the whole story.
## What it installs
Installing survivalNeedsKit brings these packages, each from its own world, at the versions it was built and tested with:
| Package | Version |
|---|---|
| SecondWind | 1.4.7 |
| barsKit | 1.4.6 |
| inventoryKit | 1.0.26 |
| worldClockKit | 1.7.3 |
## Saving
With saveKit installed (and `persist` left on), the local player's own SurvivalNeeds writes their meters to their saveKit profile under the key `survivalNeedsKit.needs` every 5 seconds when they changed, and once more when the body goes away (leaving play or the world). When the body starts again, the meters wait (at most 8 seconds) for saveKit to load the player's save, then take the saved values back, clamped 0..100, for every need the current rules run, before the first drain. A player who leaves while dead is saved with what a respawn gives them (`respawnFill`, dry, full stamina and oxygen), and a SecondWind respawn still refills the meters as before. Each player's values live in their own saveKit profile, so players never share meters. In saveKit's `checkpoint` mode the values are kept only when saveKit saves at a checkpoint. Without saveKit the kit works as before and nothing is saved.
## Multiplayer
Each player's engine owns and writes their own SurvivalNeeds; the values are synced so anyone can read them. HeatSource `burning` and `fuel` are synced and burned down by the entity's owner; `addFuel` from any peer is sent to the owner. Drinking and eating change only your own meters.
## Gallery
Put a **NeedsGallery** on any entity to step your own HUD through all six layouts and eight themes (buttons, the [ ] and - = keys, or an automatic tour) and to try every rule preset and climate with a click. The Castaway Isle world has a gallery scene with all four castaway galleries side by side.
## Guides
- **How do I add hunger and thirst to my game** (`survivalNeedsKit.package/how-do-i-add-hunger-and-thirst-to-my-game.guide`)
- **Example: island survival, stay fed, watered and warm through the night** (`survivalNeedsKit.package/example-island-survival-stay-fed-watered-and-warm-through-the-night.guide`)
## Tests
32 tests in `survivalNeedsKit.testSuite`. Run them with `asset.resolve("survivalNeedsKit", "testSuite"):run()`.
## Known limits
- Warmth from the sun is a climate number; there is no shade simulation.
- Oxygen needs a sea at height 0 (tropicalKit's island) to know when your head is under.
# deathDropKit
**When a player dies, their things stay where they fell, and they can run back and get them.** For creators asking "how do I make players drop their items when they die", "how do I add a gravestone or loot bag on death" or "how do I let players recover their stuff after dying". Seven drop styles, three looks each, five rules for what drops, and seven markers that lead the way back. Works in multiplayer: every player sees every drop, and only the right player (or anyone, under hardcore) can take it. A drop stays until its owner picks it up, even when they leave play, rejoin or the world restarts, and every death leaves its own drop.
Version 1.0.9. New in 1.0.9: released from the Castaway Isle main line together with the other survival kits, on the current engine library; no behaviour change. New in 1.0.8: a dropped bag stays where you fell and stays yours through a reconnect, a leave and rejoin and a restart (drops carry your stable `ownerId`, a bag still in the world under your old peer id is claimed back, and a saved bag that went away is put back). Built on **SecondWind** (who died), **inventoryKit** (what they carried), **interactKit** (the "E Recover" prompt on keyboard, gamepad and touch) and **navUiKit** (the waypoint and toasts), and keeps drops in **saveKit** (each player's own save).
## Quick start
In `build.luau`, on the player's body (next to SecondWind's Vitals), and in `entrypoint.luau`:
```luau
body.component.add(asset.resolve("deathDropKit.DeathDropWatcher", "component"), {})
-- entrypoint.luau
local Drops = require("~deathDropKit.drops")
function onLoad()
Drops.setup({ style = "lootBag", look = "burlap", rule = "dropAll", marker = "waypoint" })
end
```
Die with something in your bag: a burlap sack sits where you fell, a waypoint points to it, and walking up and pressing E puts everything back. Leave and come back later: the sack is still there.
## Styles and choices
| Setting | Values |
|---|---|
| `style` | `gravestone`, `lootBag`, `backpack`, `spiritOrb`, `scattered`, `crate`, `skeleton` |
| `look` | gravestone: `weathered`, `mossy`, `marble`; lootBag: `burlap`, `leather`, `royal`; backpack: `canvas`, `leather`, `scifi`; spiritOrb: `azure`, `verdant`, `ember`; scattered: `natural`, `sparkling`, `wet`; crate: `driftwood`, `shipwreck`, `cargo`; skeleton: `bleached`, `charred`, `crystal` |
| `rule` | `keepAll`, `dropAll`, `keepHotbar`, `dropHalf`, `hardcore` |
| `marker` | `waypoint`, `beam`, `flare`, `ring`, `icon`, `both`, `none` |
| `expire` | seconds until a drop crumbles away; 0 keeps it |
| `persist` | `true` (default): drops are kept in the owner's saveKit save and come back after play exit, rejoin and restart; `false`: a drop lasts only while its owner is in the world |
| Rule | What happens |
|---|---|
| `keepAll` | Nothing drops; dying only costs the walk back. |
| `dropAll` | Everything drops; only you can pick it back up. |
| `keepHotbar` | What is in your hands stays; the bag drops. |
| `dropHalf` | Half of every stack drops (rounded up); the rest stays with you. |
| `hardcore` | Everything drops and anyone can loot it. |
| Marker | What it shows |
|---|---|
| `waypoint` | A navUiKit waypoint on the compass and screen edge, only for the player who fell. |
| `beam` | A tall pale beam of light over the drop that everyone sees from across the island. |
| `flare` | A pulsing red flare column with embers rising out of it and a warm light on the ground. |
| `ring` | A slowly turning ring of glowing stones on the ground around the drop. |
| `icon` | A skull and the fallen player's name floating and bobbing over the drop. |
| `both` | The waypoint for the owner and the beam for everyone. |
| `none` | No marker: remember where you fell. |
### How taking it back works
The drop is a synced entity owned by the player who died. Pressing E sends a claim to that owner; the owner grants it once, marks it claimed and removes it, and the taker's own engine puts the items in their bag. Two players pressing at the same moment cannot both get the items. The dying player's own engine is the only one that ever takes items out of their bag.
## API
### drops module
`local Drops = require("~deathDropKit.drops")`
- `setup(opts)`: choose `style`, `look`, `rule`, `marker`, `expire` (seconds, 0 = never) and `persist` (default true); call on every peer.
- `config()`: a copy of the current settings.
- `catalogue()`: every style, look, rule and marker, for menus and agents.
- `lookOf(style, look?)`: the look a style uses (its first look when none is chosen).
- `on(event, fn)`: listen to `dropped(drop)`, `recovered(drop, items)`, `looted(drop, items, byPeer)`, `expired(drop)`, `setup(cfg)`; returns a function that stops listening.
- `takeForDeath(rule?)`: take what the local player loses under a rule out of their bag, as `{ { id, count } }`.
- `giveBack(items)`: give items to the local player (what recovering a drop does).
- `encode(items)`, `decode(s)`: turn item lists into the `id:count;id:count` text a drop holds, and back.
- `build(parent, style, look?)`: draw a style's parts under any entity (a preview, a menu).
- `list()`: every drop on this machine, `{ { id, owner, ownerName, style, items, x, y, z } }`.
- `mine()`: the local player's own drops.
- `saved()`: the local player's saved drops still waiting to be picked up, as records `{ id, style, look, marker, items, x, y, z, expireAt, anyone, ownerName }`.
- `restore(spawn?)`: put back every saved drop not already in the world (DeathDropWatcher does this on join); returns the keys it spawned.
- `record(r)`, `decodeRecords(list)`, `addRecord(list, rec)`, `removeRecord(list, id)`: check, read and edit save records.
- `isPresent(key)`, `spawnDrop(rec)`, `newKey()`: find, spawn and name drops by their stable key.
- `dropInReach()`: whether the local player is within reach of a drop they may take (what wins the prompt).
- `VERSION`, `EVENTS`, `DEFAULT_LOOK`, `SAVE_KEY`, `PROMPT_RANGE`: the version, the event names, each style's default look, the save key and the prompt reach.
### Components
**DeathDropWatcher**: on the player body; makes the drop when the player dies, and puts back the player's saved drops when they join.
- `style`, `look`, `rule` (""): override the world's settings for this player; empty follows `Drops.setup`.
- Method: `dropNow()`: leave a drop here now with the local player's things; returns the drop entity or nil.
**DeathDrop**: the drop itself, a synced entity.
- `style` ("lootBag"), `look` (""): what it looks like.
- `items` (""): what it holds, as `id:count;id:count`.
- `ownerPeer`, `ownerName`: who fell here.
- `anyone` (false): whether other players may take it (the hardcore rule).
- `expireAt` (0): `os.time()` when it crumbles away; 0 never.
- `claimed` (false): taken; it is about to disappear.
- `marker` (""): `waypoint`, `beam`, `flare`, `ring`, `icon`, `both` or `none`.
- `dropKey` (""): the drop's stable key in its owner's save.
- `beam` (false): older drops; draws the light beam like marker `beam`.
- Methods: `describe()`: `{ id, owner, ownerName, style, items, x, y, z, claimed, key }`; `takeableBy(peer)`: whether that player may take it now.
**DropGallery**: every style in every look side by side.
- `spacing` (3), `rowGap` (3.4), `labels` (true), `floor` (true).
## The prompt always goes to your drop
Standing within reach of a drop you may take (2.6 m), the "E Recover" prompt and E go to the drop, never to a rock, tree or chest beside it. interactKit has no priority setting (its prompt picks the thing you look at, then the nearest), so deathDropKit tells interactKit that the other usable things are unavailable to you while a drop is in reach. Step away from the drop and everything else works as before.
## Drops survive leaving and restarts
When you die, your own engine writes the drop into your saveKit save under `deathDropKit.drops`: `{ id, style, look, marker, items, x, y, z, expireAt, anyone, ownerName }`, one record per drop, so dying three times leaves three drops, each recoverable. The record is removed when the drop is taken or crumbles away. When you join again (or the world restarts), your engine waits for your save to load, waits a moment longer for drops still in the world to arrive, and puts back every saved drop that is not already there, matched by its `dropKey`, so a drop never appears twice. Everyone sees it again. Expired drops are forgotten instead of coming back.
## What it installs
Installing deathDropKit brings these packages, each from its own world, at the versions it was built and tested with:
| Package | Version |
|---|---|
| SecondWind | 1.4.7 |
| inventoryKit | 1.0.26 |
| interactKit | 1.6.3 |
| navUiKit | 1.3.7 |
## Gallery
Put a **DropGallery** on any entity to see all seven styles in all three looks side by side, labelled, with the rules and markers on a sign.
## Guides
- **How do I make players drop their items when they die** (`deathDropKit.package/how-do-i-make-players-drop-their-items-when-they-die.guide`)
- **Example: survival island, die, run back and get your bag** (`deathDropKit.package/example-survival-island-die-run-back-and-get-your-bag.guide`)
## Tests
24 tests in `deathDropKit.testSuite`. Run them with `asset.resolve("deathDropKit", "testSuite"):run()`.
## Known limits
- A drop belongs to the engine of the player who died; if that player leaves, their drop leaves the world with them and comes back when they return (with `persist` on). Under hardcore, other players can only loot it while its owner is in the world.
- Drops are saved through saveKit; without saveKit installed, or for a guest with no account, drops last only for the session.
- `keepHotbar` keeps exactly the amounts that were on the hotbar; inventoryKit takes items by id, so a kept stack can come back in a bag slot rather than its old hotbar slot.
- Styles are built from simple shapes so they draw on every engine with no assets to load.
# survivalCraftKit
**Make a survival game where you wash up on a small island and have to survive the night.** For creators asking "make a survival game where you survive the night", "how do I make a crafting survival island game" or "castaway game like a desert island survival". You wake on a beach with nothing, punch a palm for wood, pick up stones, find berries and coconuts, craft a stone axe, a pick, a spear and a torch, build a campfire, a shelter and a bed, cook a fish and fill a flask at the spring. At sunset things come out of the jungle that are scared of your fire. Die and your bag stays where you fell. Live until dawn and you have made it through your first night. One line builds the whole island, and one setting, the mode, picks how hard it plays.
Version 1.0.29. New in 1.0.29: shelters stay closed on sloped ground. A blueprint with pieces resting on others (lean-to, tent, pavilion, stone hearth, raised cot) stands all its walls and posts on the lowest ground under them, digging into the slope on the uphill side, so every top is level and the roof meets every wall; ground that falls more than 0.6 m across those pieces (`MAX_STEP`) is refused with "Too steep to build here" instead of leaving a gap under the roof. The hammock is a net on ropes between its two posts, without the bed frame under it (`bare = true` on a bed hides the bed piece's own look). New in 1.0.28: built against survivalNeedsKit 1.0.13, so a burning fire no longer stops heatSignatures from working. New in 1.0.27: the quick start was followed by a stranger in a new world and timed. It now leads with the fork route (playing in under a minute) and gives the fresh-world install its real time (about nine minutes, nearly all of it the first download); the how-to guide also answers "island survival game with a campfire and a shelter". New in 1.0.26: every shelter, fire and bed is built so it reads as itself from any side: the tent's two roof halves sit on its side walls and meet at the ridge, the lean-to's roof runs from a low back wall up to two front posts, the pavilion's roof sits on its four posts, the stone hearth is a fire on a raised stone plinth with a low back wall, the signal fire flies a flag, and the beds look different (palm fronds and a leaf fan, a woven mat with a rolled blanket, a hammock net on ropes to its posts, a cot on a plank floor). Blueprint pieces can `rest` on the pieces before them and beds carry `dress` parts. New in 1.0.25: built against recipeKit 1.0.5 (the craft menu on a gamepad and on small screens), nightCreaturesKit 1.0.12 (creatures close in on a player in the dark), survivalNeedsKit 1.0.11 (status chips side by side) and a clean aiKit 1.3.14 install (one navKit); the API section now says which data comes from the castaway module and which only from the presets. New in 1.0.24: the quick start and both guides describe the one-step install into a brand-new world, checked in an empty world. New in 1.0.23: installs into an empty world in one step (built against aiKit 1.3.14, whose navKit comes from one release; before, the install was refused because aiKit reached two navKit releases). New in 1.0.22: five fires (campfire, torch post, signal fire, stone hearth, torch ring), five shelters (lean-to, palm hut, tent, driftwood cabin, beach pavilion) and four beds (palm bed, bedroll, hammock, raised cot), each its own blueprint, cost and stats, swapped the same way; a burnt-out fire is cold at once and stays dark through a reconnect; the clock comes back at the hour you left (worldClockKit 1.7.3); on touch the action buttons stand clear of the needs bars, and a player who comes back with a need at zero gets a fair moment to act. New in 1.0.20 and 1.0.21: on a gamepad, Select opens only crafting (the map moved to a right-stick click; `mapPad` picks another); on touch, the Build button stands beside the action buttons where a tap reaches it, and the move stick is a fixed one, so a held tap on Eat/Use, Bag, Swing or Craft is never taken for the stick. New in 1.0.19: fires keep their fuel and stay out through a restart; the controls answer from the first frame; every dawn shows the dawn screen; Escape, Start and a pad's B close the open craft menu, bag or build mode before the pause menu (menuBackKit); and each mode also sets the craft menu's look and how fast gather spots grow back. Earlier: a campfire or torch that runs out of fuel goes dark and cold and lights again when it is fed; swing, craft, eat, the bag and the hotbar are rebindable controlsKit actions.
## Quick start
**Fastest: playing in under a minute.** Fork the Castaway Isle world, which already holds survivalCraftKit and every kit it uses, and press Play. Timed on 2026-11-15 from a stranger's first command: fork 3 s, open 5 s, island loaded at 34 s, playing at 48 s.
1. Fork it: **Fork** on the Castaway Isle page, or in the engine shell `zero zeromind fork --guid 261f357e-6a20-4912-ac33-d9972b929762`.
2. Open your fork: the ZeroMind panel, or `zero zeromind swap --guid <the guid the fork answered>`.
3. When First Night has loaded, press **Play**. You wake on the beach; the fork is your own world to change.
**Your own island in a brand-new world: about nine minutes.** The same timed run: install 7 min 49 s, the other steps under a minute. The install is the slow part: it fetches about forty packages (around 1.6 GB, art and materials included) the first time.
1. Install **survivalCraftKit** from the ZeroMind panel, or `zero zeromind installAsset --guid f395424b-1efa-4e47-9761-83a768cb3983` in the engine shell. It brings aiKit, navKit and every other kit it uses in one step. Wait for it to finish before the next step; the shell shows a report naming `survivalCraftKit.package` when it is done.
2. Make a scene (`zero scene create myIsland empty --startup`) and put this in its `build.luau`:
```luau
-- scenes/myIsland.scene/build.luau
local Island = require("survivalCraftKit.island")
function content()
Island.build({ start = "cove", mode = "castaway" })
end
```
3. Let players spawn: `zero scene player spawns` (a scene made from the empty template is playerless and would strip the island's player at play).
4. Open the scene once so tropicalKit cooks the island ground (12 s in the timed run), then press Play. You wake on the beach of the cove with your needs running; night creatures come out at dusk.
For a guided setup, run `zero workflow start --name setUpYourOwnSurvivalIsland` (the workflow is in `survivalCraftKit.package/workflows`).
## Styles and choices
### `Island.build` options
| Option | Values |
|---|---|
| `start` | `cove` (a horseshoe bay of white sand), `volcano` (a steep cone with black-sand beaches), `atoll` (a ring of sandy islets round a lagoon) |
| `mode` | `castaway`, `cozy`, `hardcore`, `creative` |
| `look` | a tropicalKit look (default `toon`) |
| `dayLengthMinutes` | real minutes per in-game day (default 16) |
| `startHour` | in-game hour you wake at (default 7) |
| `showerEveryMinutes` | how often a rain shower comes (default 9) |
| `spots` | gather spots: `{ { resource, count, nearest, farthest } }` |
| `spring` | a fresh water spring (default true) |
| `hudTheme`, `hudLayout` | override the mode's HUD (survivalNeedsKit's eight themes and six layouts) |
### Modes
One setting sets the needs rules, the HUD, the death drop and the night.
| Mode | Needs | HUD layout / theme | Death drop (style, look, rule, marker) | Night |
|---|---|---|---|---|
| `castaway` | castaway | corners / realistic | lootBag, burlap, dropAll, both | island, normal |
| `cozy` | cozy | ring / cozy | spiritOrb, azure, keepAll, ring | island, calm |
| `hardcore` | hardcore | silhouette / horror | gravestone, weathered, hardcore, flare | haunted, swarming |
| `creative` | off | minimal / minimal | backpack, canvas, keepAll, icon | no creatures |
Modes also scale what things cost (cozy half, hardcore one and a half, creative free) and what you start with.
### Recipes
| Recipe | Needs | What it does |
|---|---|---|
| Stone Axe | wood 2, stone 2, fiber 1 | Doubles palm yield; 20 damage. |
| Stone Pick | wood 2, stone 3, fiber 1 | Doubles what you get from rocks. |
| Fishing Spear (`spear`) | wood 3, stone 1, fiber 2 | 14 damage, 3 m reach, doubles fishing. |
| Coconut Flask (`waterFlask`) | coconut 1, fiber 2 | Needed to fill fresh water at the spring (up to 3 at a time). |
| Torch | wood 1, fiber 1 | A light in your hand that creatures fear. |
| Cook fish, Grill crab, Roast berries and root | raw food, by a burning fire | Cooked food. |
| Campfire, Torch post, Signal fire, Stone hearth, Torch ring | wood, stone, fiber, palm leaves | Five fires (survivalNeedsKit HeatSources): a stone hearth is the warmest and slowest to burn but lights less far; a torch ring is four torches round a camp, lots of light and little heat. |
| Lean-to, Palm hut, Tent, Driftwood cabin, Beach pavilion | wood, palm leaves, fiber, stone | Five shelters from buildPlaceKit pieces: the lean-to's roof runs from a low back wall up to two posts, the tent's two roof halves meet at the ridge over two low walls, the hut and the cabin stand on a floor (the cabin with a doorway and two windows), and the pavilion is a roof on four posts, open on every side. |
| Palm bed (`palmBed`), Bedroll, Hammock, Raised cot | palm leaves, wood, fiber | Four beds, each dressed its own way (palm fronds, a woven mat and rolled blanket, a hammock net on ropes, a cot on a plank floor): standing at one restores rest (2.5 to 5 per second by bed) and a little health. |
Every fire, shelter and bed is a blueprint in the presets (`P.FIRES`, `P.SHELTERS`, `P.BEDS`, each with an `_ORDER` list) with its own cost and stats, crafted from the craft menu and built piece by piece in front of you; the whole blueprint is checked before anything is paid, and a few nearby spots and turns are tried when the spot ahead is blocked. Add an entry to add one.
Beds are not respawn points: SecondWind has no respawn-point API.
### Switching mode while the island runs
The mode is one synced field, `mode` on the island's **CastawayGame** entity. Change it while playing (in the inspector, or `entity.find("CastawayGame").component.get(asset.resolve("survivalCraftKit.CastawayGame", "component")).mode = "hardcore"` from a script on the host) and every player's game switches on the spot: the needs rules and HUD layout and theme, the death drop style, look, rule and marker for the next death, and the night's threat set. At night the host also sends the creatures out and starts the night again with the new set. `Castaway.setup({ mode = "hardcore" })` does the same on one machine.
### Controls
The engine's own walking controls stay in charge of moving, jumping, sprinting and interacting (controlsKit's `castaway` scheme runs with `takeOver = false`), and the scheme adds Swing, Craft, Eat or use, Bag, Previous and Next slot and the hotbar's number keys on every device. CastawayPlayer answers them as controlsKit events (`Controls.on`), so they show on controlsKit's rebinding screen and its prompts, and a rebound key works at once.
| | Keyboard and mouse | Gamepad | Touch |
|---|---|---|---|
| Move | WASD | left stick | floating stick (left) |
| Jump | Space | south button | Jump button |
| Sprint | Shift | | Sprint button |
| Gather, drink, recover your bag | E | west button | Interact button or tap the prompt |
| Swing (at creatures), or feed or light the fire in reach | X | right shoulder (RB) | Swing button (above the stick) |
| Tend a fire: add fuel, or light it again once it is out (wood, palm leaves, fiber or a coconut feed it; a torch or a flint lights it) | E at the fire | west button | Interact button or tap the "Tend the fire" prompt |
| Eat or use what you hold (food, a filled flask) | F | east button (B) | Eat/Use button |
| Bag | Tab or I | left shoulder (LB) | Bag button |
| Pick a hotbar slot | 1 to 8 | d-pad left and right | tap the slot |
| Craft menu | C (click a recipe, or arrows and Enter, Esc closes) | Select (d-pad and south to pick, east closes) | Craft button (above the stick) |
| Build mode: pick a piece, a green or red ghost shows where it goes, place it; each piece costs bag items | B (wheel or 1-0 picks, R turns, click places, Esc leaves) | north button (Y; d-pad picks, RB turns, RT places, B leaves) | Build button (then tap a piece, tap the world, Place, Exit) |
### What is saved
With saveKit installed, leaving play, rejoining or restarting brings the island back as it was left: the day, hour and weather (worldClockKit's `persist`, on by default in `Island.build`; pass `persist = false` to start fresh), each player's bag (inventoryKit), each player's needs (survivalNeedsKit), death drops until their owner picks them up (deathDropKit), what was built (buildPlaceKit) and nights survived.
### What it is built from
survivalCraftKit holds only the survival rules and the wiring. Every mechanic is an installed kit:
| Part | Kit |
|---|---|
| Needs, statuses, fires, shelters, springs, food | survivalNeedsKit |
| Your things stay where you die, a marker back | deathDropKit |
| Creatures at dusk that fear firelight and leave at dawn | nightCreaturesKit (on spawnerKit; aiKit brains on navKit paths when aiKit is installed) |
| Health, damage, respawn | SecondWind (with barsKit bars) |
| Status effects from needs | abilitiesKit |
| The one bag and hotbar every kit shares | inventoryKit |
| Fires, shelters and beds as placed pieces | buildPlaceKit |
| Recipes and the craft menu | recipeKit (this world's own package; the kit defines its recipes there) |
| Gather spots | gatherKit (this world's own package), placed by `Island.build` |
| Things that run out and grow back | regrowKit (this world's own package, under every gatherKit spot) |
| Heat from fires | heatSignatures (with survivalNeedsKit's own fire falloff as the floor) |
| Day, night and weather | worldClockKit |
| The island | tropicalKit, tropicalProps, tropicalMaterials |
| Prompts | interactKit |
| Objectives, compass, toasts | navUiKit |
| Victory screen | menusKit |
| Nights survived | saveKit |
| Feedback | juiceKit |
| Keyboard, gamepad, touch | controlsKit |
## API
### island module
`local Island = require("survivalCraftKit.island")`
- `build(opts)`: build a whole survival island in a scene's `content()` (options above); returns `{ spawn = { x, y, z }, island = settings }`.
- `DEFAULT_SPOTS`: the gather spots it lays out when `spots` is not given.
### castaway module
`local Castaway = require("~survivalCraftKit.castaway")`
- `setup(opts)`: pick a mode (`castaway`, `cozy`, `hardcore`, `creative`), with optional `hudTheme` and `hudLayout`; call on every peer in onLoad.
- `config()`: a copy of the current settings.
- `mode()`: the current mode table.
- `on(event, fn)`: listen to `gathered(item, n)`, `crafted(recipe)`, `placed(kind, id)`, `refused(what, why)`, `objective(id, done)`, `won(nights)`, `tended(how, fireId)`, `setup(cfg)`; returns a function that stops listening.
- `island(start?, extra?)`: the tropicalKit Island settings for a start, with `extra` laid over them.
- `craft(recipeId)`: craft as the local player through recipeKit: an item goes in the bag, a fire, shelter or bed is built in front of them.
- `costOf(recipeId)`: what a recipe costs under the current mode (recipeKit's cost, scaled by the mode).
- `missing(recipeId)`: what the local player lacks for a recipe (empty when they can make it).
- `nearFire()`: whether the local player stands by a burning fire.
- `gather(resourceId, withTool?)`: give the local player one pick of a gatherKit resource; returns what they got.
- `_defineRecipes()`: put the kit's recipes into recipeKit for the current mode (setup calls it); cooking recipes need the "fire" station, fires, shelters and beds are placed with buildPlaceKit.
- `placeBlueprint(id, recipeId?)`: build a fire, shelter or bed blueprint 3 m in front of the local player. A spot that does not fit (no room, or too steep) is refused with a toast after a few nearby spots and turns are tried.
- `blueprintFits(id, x, z, yawDeg)`: whether a blueprint fits with its centre at a spot: every standing piece passes buildPlaceKit's own check, and a closed blueprint's ground falls no more than `MAX_STEP`. Returns fits and the refusal text.
- `footing(id, x, z, yawDeg)`: for a closed blueprint (one with `rest` pieces: a roof on walls, a fire on a plinth), the lowest and highest ground under its standing pieces; nil for an open one. Closed blueprints stand every piece on the lowest of them, so the tops stay level on a slope.
- `MAX_STEP` (0.6): how far, in metres, the ground under a closed blueprint's standing pieces may fall before the spot is too steep.
- `buildAt(id, x, groundY, z, yawDeg, direct?)`: build a blueprint at a spot; `direct = true` places it the way a scene does (host, no reach check) and returns the entities.
- `groundAt(x, z)`: ground height under a point, or nil.
- `localBody()`: the local player's body, or nil.
- `wireStatusEffects()`: give the local player an abilitiesKit Character so survivalNeedsKit's statuses land as real effects; returns an unhook function.
- `startObjectives()`: start the objective list.
- `objectiveEvent(ev, n?)`: count an event toward the objectives (`gather:<item>`, `craft:<recipe>`, `place:fire`, `place:shelter`, `eat`, `drink`, `dawn`).
- `toast(text, opts?)`: show a navUiKit toast.
- `juice(name, target?)`: play a juiceKit effect.
- `saved(key)`, `save(key, value)`: read and write saveKit values.
- `tagOf(pieceId)`, `tagInfo(pieceId)`, `tags()`, `loadTags(t)`: which blueprint a placed piece belongs to.
- Data on `Castaway` (`require("survivalCraftKit.castaway")`): `MODES`, `STARTS`, `FIRES`, `SHELTERS`, `BEDS`, `RECIPES` and `OBJECTIVES` with their order lists (`MODE_ORDER`, `START_ORDER`, `FIRE_ORDER`, `SHELTER_ORDER`, `BED_ORDER`, `RECIPE_ORDER`), plus `VERSION` and `EVENTS`, which only the castaway module has. These tables are the presets' own, so an entry added to one is seen by both.
- Data only on the presets module (`require("survivalCraftKit.presets")`): `PIECES` and `PIECE_ORDER` (what each build-mode piece takes from the bag; `Castaway.pieceCost(kind)` reads it for the current mode) and `ITEMS` (the materials, tools and foods as inventoryKit items). The castaway module does not re-export them.
- `pieceCost(kind)`: what a buildPlaceKit piece costs in the current mode (`{ item = n }`, nil when castaways cannot build it). Build mode checks it on the deciding machine against the builder's bag and takes it when the piece lands; `tended(action, fireId)` fires when the local player feeds or lights a fire.
### Components
**CastawayGame** (one, synced): runs the mode on every peer, starts the objectives, turns placed fires, roofs and beds into HeatSources, Shelters and rest spots on the host, tracks dusk and dawn, and shows the victory screen at the first dawn.
- `mode` ("castaway"), `hudTheme` (""), `hudLayout` (""): empty takes the mode's HUD.
- `isNight`, `nightsSurvived`, `won`: host-written.
- `duskAt` (0.55), `dawnAt` (0.3): darkness where night begins and ends.
- Method: `skipToDusk()` (host): advances the shared clock to 18:30.
**CastawayPlayer** (on the player body): swing, feed fires, open recipeKit's craft menu (C, pad Select, the Craft button), a torch in the hand that creatures fear, on-screen buttons.
- `torchLit` (false): owner-written, holding a lit torch.
- `reach` (2.8), `fistDamage` (8), `spearDamage` (14, reach 3 m), `axeDamage` (20).
- `torchLight` (7): how far a held torch keeps creatures back.
- `buttons` (true): show the on-screen Craft and Swing buttons.
**GatherSpot** (kept for scenes made with 1.0.5 and earlier): puts a gatherKit GatherSpot with the same `resource` on its entity and does nothing else. New scenes place `gatherKit.GatherSpot` directly.
- `resource` ("palm"): any gatherKit resource. `propScale` (1).
**ModePreview**: mode buttons that switch the game live, with the mode's death drop and night creature set shown on a stand.
- `mode` ("castaway"): the mode shown first. `panel` (true): show the buttons.
- Method: `show(id)`: switch to a mode by name.
**CastawayGallery**: every fire and shelter built for real from buildPlaceKit pieces.
- `spacing` (8), `labels` (true), `floor` (true).
## What it installs
Installing survivalCraftKit brings these packages, each from its own world, at the versions it was built and tested with:
| Package | Version |
|---|---|
| survivalNeedsKit | 1.0.13 |
| deathDropKit | 1.0.9 |
| nightCreaturesKit | 1.0.13 |
| inventoryKit | 1.0.26 |
| buildPlaceKit | 1.0.35 |
| interactKit | 1.6.3 |
| navUiKit | 1.3.7 |
| menusKit | 1.3.19 |
| saveKit | 1.3.13 |
| juiceKit | 1.2.10 |
| controlsKit | 1.3.2 |
| SecondWind | 1.4.7 |
| worldClockKit | 1.7.3 |
| tropicalKit | 1.0.4 |
| tropicalProps | 1.0.2 |
| tropicalMaterials | 1.0.2 |
| spawnerKit | 1.1.8 |
| barsKit | 1.4.6 |
| abilitiesKit | 1.1.4 |
| recipeKit | 1.0.6 |
| gatherKit | 1.0.4 |
| regrowKit | 1.0.2 |
| aiKit | 1.3.16 |
| heatSignatures | 1.0.9 |
| menuBackKit | 1.0.2 |
## Multiplayer
Fires, shelters and creatures are decided by the host and seen by everyone. Each player has their own needs, their own bag (inventoryKit, owner-written) and their own objectives; a dropped bag is seen by all and taken back only by its owner (or anyone, in hardcore). A gather spot's charges are decided by its owner so two players never take the same pick.
## Gallery
Put a **CastawayGallery** on a synced entity in a scene of its own to see all five fires, five shelters and four beds built for real from buildPlaceKit pieces, with the four modes and three island starts on signs. Put a **ModePreview** beside it to flip between modes. The Castaway Isle world ships a gallery scene with every castaway gallery side by side.
## Guides
- **How do I make a survival game where you survive the night** (`survivalCraftKit.package/how-do-i-make-a-survival-game-where-you-survive-the-night.guide`)
- **Example: make a survival game where you survive the night on an island** (`survivalCraftKit.package/example-make-a-survival-game-where-you-survive-the-night-on-an-island.guide`)
- **Workflow: set up your own survival island** (`zero workflow start --name setUpYourOwnSurvivalIsland`)
## Tests
18 tests in `survivalCraftKit.testSuite`. Run them with `asset.resolve("survivalCraftKit", "testSuite"):run()`.
## Known limits
- craftingKit cannot be installed into this world yet (platform issue #25685), so recipes and the craft menu come from recipeKit and gathering from gatherKit and regrowKit, three small packages published from this world.
- Beds restore rest but are not respawn points.
# recipeKit
Recipes and a craft menu for any crafting game. If you are asking "how do I add crafting to my game", this is the small, standalone answer: define recipes (what they need, what they give, whether they need a fire or a workbench, or whether the game places them in the world), and open a craft menu that works with mouse, touch and gamepad. Crafting reads and changes the player's own inventoryKit bag. Ready packs cover survival crafting out of the box: recipes for a stone axe, a torch, a stone pick, a fishing spear, a coconut flask, a campfire, cooking at a fire, and walls, floors and roofs.
Version 1.0.6. New in 1.0.6: released from the Castaway Isle main line together with the other survival kits, on the current engine library; no behaviour change. New in 1.0.5: on a gamepad the d-pad and the left stick move the highlight through every recipe (each row names the row above and below it for the engine's focus moves, so focus never jumps to Close; holding repeats), and the list fits the screen on any size: it shows as many rows as fit in 90% of the screen's height (`MAX_HEIGHT`) and scrolls with the highlight, with "more above / below" markers you can tap or click and a mouse wheel that scrolls. New in 1.0.4: a gamepad drives the craft menu through the engine's own menu navigation (d-pad or stick moves, south crafts, east closes) and the highlighted recipe follows the focused row; while open the menu holds Back, and with menuBackKit installed Escape and Start close it before the pause menu. Gamepad buttons are read through its own padButtons input map first (Menu.padDown), since some clients deliver a pad press only through input maps. On a touch screen the craft menu reads finger taps itself, so tapping a recipe crafts it and tapping Close closes it (a tap can only hover a button in some builds).
## Example
```lua
local Recipes = require("recipeKit.recipes")
local Menu = require("recipeKit.menu")
Recipes.loadPack("survivalBasics")
Recipes.define("rope", { label = "Rope", needs = { fiber = 3 }, result = { "rope", 1 }, category = "tools" })
Recipes.setStationCheck(function(station) return station ~= "fire" or myGame.nearFire() end)
Recipes.onPlace(function(id, recipe) return myGame.placeInFront(recipe.place, function() return Recipes.pay(id) end) end)
-- on the player's body: C or pad Select opens the menu
body.component.add(asset.resolve("recipeKit.CraftMenu", "component"), { theme = "rustic", layout = "list" })
```
## Styles and options
| option | values |
|---|---|
| `theme` | `rustic` (default, brown and gold), `scifi`, `cartoon`, `pixel`, `minimal`, `cozy`. Each sets colours, corner radius and font. |
| `layout` | `list` (one column list, default), `grid` (two column grid) |
| `title` | the menu's title, default `Crafting` |
| `categories` | only show recipes of these categories, e.g. `{ "cooking" }`; nil shows all |
| packs | `survivalBasics` (stone axe, stone pick, torch, fishing spear, coconut flask, campfire to place), `cooking` (cooked fish, grilled crab, roasted root, fish stew, all at a fire), `building` (wall, floor, roof to place) |
| cost scale | `Recipes.setScale(k)`: every cost times k, rounded up; 0 makes everything free |
**Station recipes.** A recipe with `station = "fire"` (or `"workbench"`, or any name) can only be made where your station check says yes. The menu marks it "(at a fire)" and a refusal toasts "Stand by a fire". Without a check every station passes.
**Place recipes.** A recipe with `place = "campfire"` gives no item: once the checks pass, `craft` calls your `onPlace(id, recipe)` handler, which builds it and takes the cost with `Recipes.pay(id)` when it really places. Return `false, "why"` to refuse.
**The menu.** Each recipe is a button with its cost; what you cannot make yet is greyed out; the selected row has a highlight border; a Close button closes it. The mouse pointer is freed while the menu is open and the game gets it back when it closes.
**Controls.**
| input | what it does |
|---|---|
| mouse or touch | click or tap a row to craft it; hovering a row highlights it; Close closes |
| keyboard | Up and Down arrows or W and S move the highlight (Left and Right too in the grid), Enter or E crafts the highlighted row, Escape closes. Held keys repeat after 0.35 s. `menu.keyboard(false)` turns the keys off. |
| gamepad | d-pad moves (left and right too in the grid), south (A) crafts, east (B) closes |
| open and close | C or pad Select with the CraftMenu component, or `menu.toggle()` from your own controls |
## API
### recipes module (`require("recipeKit.recipes")`)
| call | what it does |
|---|---|
| `VERSION` | `"1.0.4"` |
| `define(id, def)` | define or replace a recipe. `def = { label, needs = { item = n }, result = { item, n }?, place = string?, station = string?, category = string? }`; needs a result or a place. Returns the stored recipe. |
| `remove(id)` | remove a recipe; returns whether it existed |
| `get(id)` | the recipe or nil |
| `list(category?)` | recipes in definition order |
| `order` | the id list behind `list` |
| `setOrder(ids)` | put these ids first, in this order |
| `categories()` | categories in use |
| `loadPack(name)` | define a ready pack; returns its ids |
| `setScale(k)`, `scale()` | cost multiplier (ceil, 0 is free) |
| `costOf(id)` | `{ item = n }` after scaling |
| `costText(id)` | `"2 stone, 1 fiber"` or `"free"` |
| `missing(id)` | what the local player lacks: `{ item = n }` |
| `missingText(miss)` | `"Needs 2 stone, 1 fiber"` |
| `canMake(id)` | `(true)` or `(false, why)`, including the station check |
| `setStationCheck(fn)` | `fn(station) -> boolean`; nil restores the default (every station passes) |
| `atStation(station?)` | the station check's answer |
| `onPlace(fn)` | `fn(id, recipe) -> (ok, why?)`, the game's handler for place recipes |
| `pay(id)` | take the scaled cost from the bag; refuses (takes nothing) when short |
| `craft(id)` | check, pay, give the result (`Inventory.give(item, n, true)`) or call the place handler, toast and emit. Returns `(ok, why?)` |
| `on(event, fn)` | listen; returns an unsubscribe function. Events: `crafted(id)`, `refused(id, why)`, `defined(id)` |
| `toast(text, opts?)` | a navUiKit toast when navUiKit is installed |
| `reset()` | remove every recipe and listener and restore the defaults |
### menu module (`require("recipeKit.menu")`)
| call | what it does |
|---|---|
| `THEMES`, `THEME_ORDER`, `THEME_KEYS` | the six themes, their order, and the keys every theme sets |
| `LAYOUTS` | `{ { id = "list", columns = 1 }, { id = "grid", columns = 2 } }` |
| `setup({ theme, layout, title, categories })` | pick the look; unknown names are refused |
| `config()` | the current settings |
| `open()`, `close()`, `toggle()`, `isOpen()` | show and hide the menu |
| `move(delta)` | move the highlight, wrapping at either end |
| `nextIndex(sel, n, delta)` | pure: the row `delta` steps on among `n`, wrapping |
| `dirDelta(dir, columns)` | pure: how far `up`, `down`, `left`, `right` move with this many columns (left and right are 0 in a list) |
| `repeatStep(rec, down, now, delay?, rate?)` | pure: key repeat, true on the press and then every `rate` s once held `delay` s |
| `keyboard(on?)` | turn the menu's keyboard handling on or off; returns the setting |
| `indexOf(id)` | the row a recipe sits on |
| `selected()` | the highlighted row |
| `pick()` | craft the highlighted recipe (a click and a key on the same press craft once) |
| `items()` | the recipes the menu shows |
| `refresh()` | redraw when open |
| `tree()` | the widget tree as it would draw now |
| `step()` | every frame: poll keys and pad (presses fire once, held moves repeat), highlight the hovered row and redraw twice a second |
| `padDown(button)` | whether a pad button is held on any pad |
### packs module (`require("recipeKit.packs")`)
`PACKS[name] = { label, description, order, recipes }` and `ORDER`.
### Components
- **CraftMenu**: on the player's body; only its owner acts. Fields `theme` (`rustic`), `layout` (`list`), `openKey` (`KeyC`, empty for none), `padButton` (`select`, empty for none), `title` (`Crafting`). A game with its own controls (controlsKit actions) sets `openKey = ""` and `padButton = ""` and calls `menu.toggle()` itself.
- **RecipeGallery**: on any entity; opens the menu in each theme in turn with a button panel to switch theme and layout. Local only.
## Multiplayer
Crafting is local to each player's own bag: `missing`, `pay` and `craft` read and change only the local player's inventoryKit inventory, which inventoryKit replicates and saves. The menu is drawn on each player's own screen, and CraftMenu acts only on the engine that owns the body. Recipes are plain data: define the same ones on every peer (from a scene entrypoint or a module every peer requires). What a `place` recipe builds is the game's to replicate.
## Tests
`recipeKit.testSuite` checks defining, listing and ordering, cost scaling (including 0 and rounding up), missing with no bag, the station check, refusals, the place handler, packs, the menu (open, close, move wrapping, grid moves, key repeat, row clicks, the click and key guard, themes) and events. Run it with `asset.resolve("recipeKit", "testSuite"):run()`.
## Guides
- **How do I add crafting recipes and a craft menu to my game** (`recipeKit.package/how-do-i-add-crafting-recipes-and-a-craft-menu-to-my-game.guide`)
- **Example: craft a stone axe and a torch on a survival island** (`recipeKit.package/example-craft-a-stone-axe-and-a-torch-on-a-survival-island.guide`)
## What it installs
Installing recipeKit brings these packages, each from its own world, at the versions it was built and tested with:
| Package | Version |
|---|---|
| inventoryKit | 1.0.26 |
| menuBackKit | 1.0.1 |
# nightCreaturesKit
**Things come out of the jungle when the sun goes down. They are scared of your fire, and they leave at dawn.** For creators asking "how do I add monsters that come out at night", "make a survival game where you survive the night" or "enemies that fear fire". Eight creatures, two looks each, four threat sets and three densities, each switched with one setting. Multiplayer: the host decides, every player sees the same creatures.
Version 1.0.13 (built against aiKit 1.3.16 and navKit 1.5.0, so it installs beside them as one release of each). New in 1.0.13: released from the Castaway Isle main line together with the other survival kits, against aiKit 1.3.16; no behaviour change. New in 1.0.12: the night is dangerous off the paths too. A navKit map stops short of beaches, piers and camps, so a creature hunting a player standing there used to wait at the map's edge; now, within 14 m of a player in the dark, it drops its path and runs straight at them (the new `rushed(id)` event), and takes the path again once the player is 30 m away. Firelight and a held torch still turn it away at the edge of the light. Built on **spawnerKit** (each creature is a spawnerKit enemy: spawn effects, pooling, contact damage), **SecondWind** (their health, your damage) and **worldClockKit** (dusk and dawn from the shared clock). Reads firelight from **survivalNeedsKit** HeatSources when it is installed. When **aiKit** is installed, each creature gets an aiKit brain (the `swarm` preset for crabs, bats and wisps, `chaser` for the rest) that hunts players along **navKit** paths, round rocks, trees and buildings: the NightDirector bakes a navKit waypoint map of the island on every peer when play starts (`navMap`, `navSize`, `navSpacing`, `navCell`; about 5 to 12 seconds for the whole island), since a brain with no map never moves. Creatures prowl a clear 2.5 m outside the light. Near firelight the director switches the brain off and walks the creature round the edge of the light on navKit paths, circling for as long as a player stands inside it, and at dawn it walks every creature away into the dark the same way before spawnerKit removes it.
**The dawn rule:** at dawn no new group spawns, every creature walks or flies away from the nearest player into the dark, and any creature still in play `leaveSeconds` (12) after it was sent away is removed by the host through spawnerKit. Nothing stays on the beach in daylight.
## Quick start
In `build.luau`, inside `content()`, and in `entrypoint.luau`:
```luau
local SK = require("spawnerKit.api")
local night = entity.spawnSynced("NightDirector")
SK.addSpawner(night, { pattern = "ring", effect = "auto", autoStart = false })
night.component.add(asset.resolve("nightCreaturesKit.NightDirector", "component"), {})
-- entrypoint.luau
local Creatures = require("~nightCreaturesKit.creatures")
function onLoad()
Creatures.setup({ threat = "island", density = "normal" })
end
```
You need a WorldClock in the scene (worldClockKit) so there is a dusk and a dawn.
## Styles and choices
| Setting | Values |
|---|---|
| `threat` | `island` (crabs, bats, drowned sailors, a jungle cat, wisps), `forest` (wolves, bats, spiders, a panther), `haunted` (stalkers, wisps, a drowned captain, vampire bats, ghost crabs), `arctic` (dire wolves, a smoke stalker, bats) |
| `density` | `calm`, `normal`, `swarming` |
| `enabled` | false keeps nights empty (creative) |
| Creature | Looks | Health | Speed | Group | Fear of fire |
|---|---|---|---|---|---|
| Crab swarm | sand, ghost | 18 | 3.4 | 6 | strong |
| Wolf pack | timber, dire | 45 | 4.6 | 3 | prowls the edge |
| Shadow stalker | void, smoke | 70 | 3.0 | 1 | never enters light |
| Bats | fruit, vampire | 10 | 5.5 (flying) | 5 | strong |
| Drowned sailor | deckhand, captain | 60 | 2.2 | 2 | dares the edge |
| Jungle cat | jaguar, panther | 55 | 5.2 | 1 | prowls the edge |
| Giant spider | huntsman, widow | 50 | 3.8 | 2 | strong |
| Will-o'-the-wisp | marsh, spectral | 20 | 2.6 (ranged) | 2 | none; burns out at dawn |
### How the night runs
1. When the clock's darkness passes `duskAt` (0.55) the host's NightDirector starts night number N: every peer hears `dusk`.
2. Every `interval` seconds it releases a group from the threat set: it moves its Spawner to a dry, dark spot about 30 m from a random player (never inside firelight) and spawns the group there with spawnerKit's ring pattern.
3. Four times a second it steers every creature: one that strays into firelight turns to wander just past the light's edge, so they circle your camp; out in the dark they chase the nearest player (with aiKit, their brain hunts along navKit paths).
4. When darkness falls below `dawnAt` (0.3) no new group is released and every creature walks away into the dark (with aiKit, its brain and navKit agent come off first, so nothing holds it in place); any still in play `leaveSeconds` (12) after it left is sent back to spawnerKit's pool. Every peer hears `dawn`; the host fires `retreat` once and `fled(id)` per creature.
Light comes from `Creatures.lightAt`: survivalNeedsKit HeatSources (campfires, torches) plus anything you register with `Creatures.addLight(entity, radius)`, such as a torch in a player's hand.
## API
### creatures module
`local Creatures = require("~nightCreaturesKit.creatures")`
- `setup(opts)`: choose `threat`, `density` and `enabled`; call on every peer.
- `config()`: a copy of the current settings.
- `catalogue()`: every creature, look, threat set and density, for menus and agents.
- `on(event, fn)`: listen to `dusk(night)`, `dawn(night)`, `spawned(kind, n)`, `fled(id)`, `retreat()`, `setup(cfg)`; spawned, fled and retreat fire on the host. Returns a function that stops listening.
- `darkness()`: how dark it is by the shared clock (0 day, 1 night).
- `addLight(entity, radius)`: register a light creatures fear; returns a function that removes it.
- `lightAt(x, y, z)`: light at a point (0..1): survivalNeedsKit fires plus registered lights.
- `lights()`: every light creatures fear, `{ { x, z, r } }`.
- `build(root, creature, look?)`: draw a creature under any entity (a bestiary, a menu).
- `kindId(creature)`: the spawnerKit enemy kind id (`"night_wolfPack"`).
- `creatureOf(kindId)`: the creature behind a spawnerKit kind id, or nil.
- `defineAll()`: register every creature as a spawnerKit enemy kind (setup calls it).
- `pick(r?)`: pick a creature and look from the threat set by weight.
- `dawnRemovals(sinceDawn, leaveSeconds?)`: the dawn rule as a pure function: given `{ [id] = seconds since it was sent away }`, the sorted ids that must be removed now (default `LEAVE_SECONDS`, 12).
- `VERSION`, `EVENTS`, `DENSITY`, `PREFIX`, `LEAVE_SECONDS`: the version, event names, density table, kind id prefix and default dawn window.
### Components
**NightDirector**: on a synced entity with a spawnerKit Spawner; runs the nights on the host.
- `night` (false): whether the creatures are out (host-written).
- `nightNumber` (0): how many nights have begun (host-written).
- `groupsSent` (0): groups released this night (host-written).
- `spawnDistance` (30): how far from a player a group appears.
- `bringCreatures` (true): off keeps nights empty (creative).
- `leaveSeconds` (12): seconds a creature has to walk away at dawn before the host removes it.
- Methods: `startNight()` (host; for testing and scripted events), `endNight()` (host; sends every creature away).
**CreatureGallery**: all eight creatures in both looks in a turning, labelled lineup.
- `spacing` (3.2), `rowGap` (4), `labels` (true), `floor` (true), `turn` (true).
## What it installs
Installing nightCreaturesKit brings these packages, each from its own world, at the versions it was built and tested with:
| Package | Version |
|---|---|
| spawnerKit | 1.1.8 |
| SecondWind | 1.4.7 |
| worldClockKit | 1.7.3 |
## Gallery
Put a **CreatureGallery** on any entity to see all eight creatures in both looks in a turning, labelled lineup, with each threat set and density on a sign.
## Guides
- **How do I add monsters that come out at night and fear fire** (`nightCreaturesKit.package/how-do-i-add-monsters-that-come-out-at-night-and-fear-fire.guide`)
- **Example: survive the night on an island with a campfire** (`nightCreaturesKit.package/example-survive-the-night-on-an-island-with-a-campfire.guide`)
## Tests
19 tests in `nightCreaturesKit.testSuite`. Run them with `asset.resolve("nightCreaturesKit", "testSuite"):run()`.
## Known limits
- Without aiKit, creatures walk straight at their target over the ground (spawnerKit's movement), so they do not path round cliffs. With aiKit they walk navKit paths; the NightDirector bakes that map itself when play starts (5 to 12 s), and until it is ready the creatures wait at their spawn.
- Creatures are drawn from simple shapes, with no animation rig.
# gatherKit
**Gather spots for any survival or crafting game: walk up, press the prompt, get items in your bag; spots run out and grow back.** For creators asking "how do I add resource gathering to my game", "how do I let players punch trees for wood", "how do I make gather nodes" or "how do I let players pick berries in a survival game". Fifteen resources (palms, rocks, berry bushes, driftwood, grass, fishing pools, bananas, mushrooms, clam beds, reeds, flint, fallen coconuts, seaweed, ore veins and ferns), each with what one pick gives, a tool that doubles it, how many picks it holds and how fast it grows back. Works in multiplayer: every pick is decided by the spot's owner, so two players never get the same one.
Version 1.0.4. New in 1.0.4: released from the Castaway Isle main line together with the other survival kits, on the current engine library; no behaviour change. New in 1.0.3: the gallery rebuilds when a resource changes, so a game's mode giving every spot one regrow pace shows at once.
## Quick start
In `build.luau` (or any script that builds your scene), on synced entities:
```luau
local spot = asset.resolve("gatherKit.GatherSpot", "component")
local palm = entity.spawnSynced("Palm1", { position = { 12, 0, 40 } })
palm.component.add(spot, { resource = "palm" })
local bush = entity.spawnSynced("Bush1", { position = { 16, 0, 38 } })
bush.component.add(spot, { resource = "bush" })
-- anywhere, to react to what players gather
local Gather = require("~gatherKit.gather")
Gather.on("gathered", function(item, n, resourceId) print("got", n, item, "from", resourceId) end)
```
Walk up to the palm, press E (pad X, or tap): wood and palm leaves land in your bag and a toast says what you got. After five punches the palm shrinks back and its prompt reads "Grows back soon"; five minutes later it grows back.
## Resources and options
| Resource | Label | One pick gives | Tool (doubles) | Picks | Regrow | Prop |
|---|---|---|---|---|---|---|
| `palm` | Palm tree | 1-2 wood, 0-1 palmLeaf, 1 coconut (35%) | stoneAxe | 5 | slow | palmCoconutStraight |
| `rock` | Loose stones | 1-2 stone | stonePick | 6 | normal | rockBeach |
| `bush` | Berry bush | 1-3 berries, 0-1 fiber | none | 4 | normal | hibiscusBush |
| `driftwood` | Driftwood | 1-3 wood | stoneAxe | 2 | slow | driftwoodLog |
| `grass` | Tall grass | 1-2 fiber | none | 5 | quick | beachGrass |
| `fishing` | Fishing pool | 1 rawFish, 1 crabMeat (30%) | spear | 3 | hourly | a shallow pool |
| `banana` | Banana plant | 1-2 banana, 0-1 palmLeaf | none | 3 | slow | palmYoung |
| `mushroom` | Mushroom patch | 1-2 mushroom, 1 fiber (25%) | none | 3 | normal | tropicalUndergrowth |
| `clamBed` | Clam bed | 1 crabMeat, 0-1 seaweed, 1-2 shell (50%) | spear | 3 | hourly | shellScatter |
| `reeds` | Reeds | 1-2 reed, 1 fiber | stoneAxe | 4 | quick | seaOats |
| `flint` | Flint scatter | 1 flint, 0-1 stone | stonePick | 3 | slow | pebbleScatter |
| `coconutPile` | Fallen coconuts | 1-2 coconut | none | 2 | slow | coconutPile |
| `seaweed` | Seaweed | 1-2 seaweed, 1 fiber (40%) | none | 4 | quick | seaweedLine |
| `oreVein` | Ore vein | 1-2 stone, 1 ore (60%) | stonePick | 4 | daily | rockBasalt |
| `fern` | Fern | 1-2 fiber, 0-1 palmLeaf | none | 3 | quick | fernTropical |
Regrow presets come from regrowKit: `quick` 30 s, `normal` 90 s, `slow` 5 min, `hourly` 1 in-game hour (150 s without worldClockKit), `daily` 1 in-game day (600 s without it), `never`. A resource may give a number of seconds instead.
GatherSpot fields: `resource` (default `palm`), `propScale` (default 1), `prompt` (default true; off leaves the prompt to you). To change how a spot runs out, put your own regrowKit `Regrowing` on the entity before GatherSpot (its `maxCharges`, `regrow`, `spentLook` hide, shrink, fade or none); GatherSpot keeps one that is already there.
Items: gatherKit defines the materials and tools it gives (stone, fiber, palmLeaf, wood, flint, ore, reed, shell, mushroom, stoneAxe, stonePick) in inventoryKit only when no other kit has. Foods (coconut, berries, banana, rawFish, crabMeat, seaweed) are survivalNeedsKit's, so they are edible when it is installed; without it gatherKit adds plain versions.
## API
### gather module
`local Gather = require("~gatherKit.gather")`
| Call | What it does |
|---|---|
| `Gather.VERSION` | `"1.0.0"` |
| `Gather.RESOURCES` | `{ [id] = { label, verb, gives = { { item, min, max, chance? } }, tool?, charges, regrow, prop, category } }` |
| `Gather.RESOURCE_ORDER` | Resource ids in display order. |
| `Gather.define(id, def)` | Add or replace a resource; gives may be `{ item = , min = , max = , chance = }` or `{ item, min, max, chance }`. Errors naming what is wrong. Returns the stored resource. |
| `Gather.roll(id, withTool, rng?)` | One pick, rolled without touching any bag: `{ { id, count } }`. `rng` returns 0..1 (default `math.random`); a chance passes when `rng() < chance`; the tool doubles every count. |
| `Gather.give(id, withTool)` | Roll a pick into the local player's inventoryKit bag (leftovers drop at their feet). Emits `gathered` per item; returns what was given. Does nothing outside play or without inventoryKit. |
| `Gather.hasTool(id)` | Whether the local player carries the resource's tool. |
| `Gather.items()` | Every item id the resources give or use as a tool, sorted; defines the ones inventoryKit lacks. |
| `Gather.describe(got)` | `"+2 Wood +1 Palm Leaf"` for a list from `give` or `roll`. |
| `Gather.on(event, fn)` | Listen; returns unsubscribe. `gathered(item, n, resourceId)`, `picked(resourceId, entityId)`, `empty(resourceId, entityId)`. |
| `Gather.ITEMS`, `Gather.FOOD_FALLBACK` | The item definitions gatherKit adds when missing. |
### Components
| Component | What it does |
|---|---|
| `gatherKit.GatherSpot` | On a synced entity: draws the resource's tropicalProps prop as a child `gatherProp`, adds a regrowKit Regrowing (resource charges and regrow) if there is none, and an interactKit prompt reading the verb, or "Grows back soon" when spent. Using it takes a charge through `regrowKit.take`, then gives the pick, toasts it (navUiKit) and plays juiceKit `dust`. |
| `gatherKit.GatherGallery` | Every resource as a working spot in one labelled row (gives, tool, picks, regrow). Local and temporary; safe in any scene. |
## Multiplayer
Put GatherSpot on synced entities. The prop and prompt are drawn on every peer; the Regrowing charges are synced and written only by the entity's owner. A player pressing the prompt asks the owner through `regrowKit.take`; the owner spends one charge and answers that player alone, and only then does that player's own engine roll the pick into their own bag. Two players pressing at once get one charge each while charges last, never the same one. The spent look and the "Grows back soon" prompt follow the synced charges, so everyone sees the same bush.
## Tests
`asset.resolve("gatherKit", "testSuite"):run()` runs 17 tests: every resource complete with valid items, tools and props; roll with fixed random sources (min, max, chance, tool doubling); define; events; give outside play doing nothing safely; items defining its materials; GatherSpot adding a Regrowing with the resource's charges, its prop and prompt; GatherGallery; and the README and version against the code.
## Guides
- *How do I add resource gathering to my survival game* (`gatherKit.package/how-do-i-add-resource-gathering-to-my-survival-game.guide`): the ideas, the resources, tools, regrowing, multiplayer and your own resources.
- *Example: punch palms and pick berries on an island* (`gatherKit.package/example-punch-palms-and-pick-berries-on-an-island.guide`): a worked example from an empty island to a gathering loop with a stone axe.
## What it installs
Installing gatherKit brings these packages, each from its own world, at the versions it was built and tested with:
| Package | Version |
|---|---|
| inventoryKit | 1.0.26 |
| interactKit | 1.6.3 |
| regrowKit | 1.0.2 |