Low Water
README.md
floodKit: water that rises and drains on cue
Water a game raises and lowers when it wants to: a corridor that floods behind the player, a
gallery filling while you run for the exit, a reservoir refilling at the finale, a basin that
drains to open a way down, a sluice that steps the water up stage by stage. Put a
floodKit.FloodVolume on a box-shaped room, then call Flood.fill, Flood.drain or Flood.to
from a trigger, a button, a timer or a scripted beat.
The water is Tidewater's (lakes, pools, seven looks, reflections, caustics, the view from under the surface, and physics water the engine floats things on), so whatever floats on Tidewater floats on a flood, and every style has its own curve, sounds and effects. Every player sees the same level at the same moment, and a player who joins late sees it where it is.
First example
local Flood = require("floodKit.api")
local gallery = entity.spawnSynced("Gallery", { position = { 0, 0, -40 } })
gallery.component.add("floodKit.FloodVolume", { size = { x = 12, y = 3, z = 8 }, high = 1.2, style = "surge" })
Flood.to("Gallery", 1.2, 20, "surge") -- 1.2 m of water over 20 s, a torrent that slows as it fills
The entity stands at the floor of the room, in its middle; size is the box the water fills
(width x, height y, length z). Levels are metres above the floor. In a scene, put the first three
lines in the scene's build.luau (inside content()) so the volume is saved with the scene, and
call Flood.* from your game code. Use entity.spawnSynced for the volume so its moves are shared
in multiplayer.
Styles
| Style | What it does | Sounds | Effects | Default time (low to high) |
|---|---|---|---|---|
steady | An even rise with soft starts and stops | water pouring from a feed pipe | foam at the inlet, rings | 12 s |
surge | A fast front that slows as the room fills | roaring torrent with a low rumble | heavy foam and spray at the inlet, churning rings | 6 s |
stepped | Sluice stages: the gate opens with a clunk, the water climbs a step, holds, again (stages, default 4) | pouring, an iron clunk at each stage | a spray burst and ring at each clunk | 16 s |
seep | A slow creeping rise that pulses as water finds its way in | drips and trickles | drips running down the walls | 40 s |
drain | Lowers fastest while deep and tails off at the end (water emptying through a hole) | a deep gurgle at the drain | a swirl of rings and foam over drainPoint | 14 s |
slosh | Overshoots its target by about 12% and settles onto it | heavy water slapping the walls | waves running wall to wall | 8 s |
tidal | Keeps rising and falling between two levels until stopped (seconds each way) | gentle lapping | rings | 20 s each way |
Every move ends with a splash and its sound (seep and tidal excepted). seconds = 0 on the volume
uses the times above, in proportion to how far the water moves. Aliases work too: rush, sluice,
leak, gurgle, wave, tide and friends.
The component: floodKit.FloodVolume
| Field | Default | What it is |
|---|---|---|
low / high | 0 / 1.2 | the drained and the full level, metres above the floor |
start | "low" | where the water stands when the scene starts: "low", "high" or a number |
style | "steady" | the style fill uses (and drain when it is stepped, slosh or steady; otherwise drain uses drain) |
seconds | 0 | a full low to high move in seconds (0 = the style's own) |
stages | 4 | stepped: sluice stages per move |
size | 8 x 3 x 6 | the box the water fills, centred on the entity, floor at its origin |
kind / look / preset | lake / realistic / "" | how Tidewater draws it (pool, pond, hotspring, underwater; any of the seven looks; any preset of the kind, e.g. murkyPond, darkPeat, glacierMilky) |
inlet / drainPoint | the -x wall / the floor's middle | where water comes in and goes out, in the entity's space (foam, the rush and clunks play at the inlet; the gurgle and the swirl at the drain) |
sounds / effects / volume | on / on / 0.8 | the style's sounds and effects |
slowWading | on | slow a player wading here |
drowning / breathSeconds | off / 12 | hurt a player whose head stays under longer than this |
An entity that already carries a Tidewater WaterBody keeps it: the volume drives that water's
level and takes its size from it. Methods on the component: :to(level, seconds?, style?),
:fill(), :drain(), :stop(), :level().
floodKit.FloodSwitch is a switch a player uses: put it on a lever or a button, set target to
the volume's name and action to toggle, fill, drain, stop or cycle (start or stop a
tidal swing). A prompt floats over it when a player is near; Interact (E, the pad's west button or
the on-screen button) presses it. Only the nearest switch answers.
API: local Flood = require("floodKit.api")
| Call | What it does |
|---|---|
Flood.to(nameOrEntity, level, seconds?, style?) | move the water to level (metres, or "high" / "low"); answers false when no such volume is loaded |
Flood.fill(name) / Flood.drain(name) / Flood.toggle(name) | to high / to low / whichever is farther |
Flood.stop(name) | hold the water where it is (stops a tidal swing) |
Flood.level(name) | the level now, metres above the floor (nil when not loaded) |
Flood.surfaceY(name) | the surface's world height now |
Flood.moving(name), Flood.state(name), Flood.list() | whether it moves; { level, from, to, startAt, seconds, style, seq, stopped, low, high, rate }; every volume's name |
Flood.onReached(name or "*", fn(name, level)) | called once each time a move arrives (a tidal volume at each high and low water), on every peer; answers a function that stops listening |
Flood.depthAt(position) | how deep the water stands over a point (0 when dry), and which volume: pass a player's feet to learn how deep they wade |
Flood.onDrowning(fn(info)), Flood.breath() | the local player is drowning ({ player, volume, underSeconds, damage } each tick once the breath is gone); seconds of breath left, for a breath bar |
Flood.useSecondWind(HK), Flood.useScriptedEvents(Cues) | hand floodKit those kits' APIs (see below) |
Flood.hooks | slow, slowAtWaist (0.45: the share of walking speed left at 1.1 m), drowning, damagePerSecond (12), headHeight (1.55) |
Flood.styles | the seven style names |
Wading slows the local player's CharacterController (its moveSpeed, and sprint fades out)
the deeper they stand, and puts the speed back on dry land. A body that swims with
tidewaterSwim (a Swimmer on it) is left to it. Drowning is off unless a volume sets
drowning = true: once the player's head has been under for breathSeconds, they take
damagePerSecond, and Flood.onDrowning listeners hear it. With SecondWind, the damage goes
through a Vitals on the player's body by itself; for SecondWind's full rules (armour, damage
types, the kill feed) hand floodKit its API once in your game code:
Flood.useSecondWind(require("SecondWind.api")) -- drowning hurts through HK.damage, type "environment"
Scripted events (scriptedEventsKit)
With scriptedEventsKit in your world, hand floodKit its API once and cues get a flood beat
(host scope); the beat holds the timeline for the move when it has wait = true:
Flood.useScriptedEvents(require("scriptedEventsKit.api"))
-- then, in a cue's beats:
{ "flood", "Gallery", 1.2, seconds = 20, style = "surge", wait = true } -- level: metres, "high", "low", "fill", "drain" or "stop"
floodKit never depends on scriptedEventsKit, SecondWind or tidewaterSwim. A published package may only name what it depends on, so floodKit finds their components by identity at runtime and takes their APIs from these two calls, which live in your game's code, where the kits are installed. Without them everything else works.
Multiplayer
Host authoritative and synced. A move is six Sync fields on the volume (moveFrom, moveTo,
moveStart on the session clock, moveSeconds, moveStyle, moveSeq), written by the peer
that owns the volume's entity, or by the host when no peer owns it (how a scene's synced entity
stands in play: owner() reads 0 and isLocal() is false on every peer). Every peer draws the level
from those and multiplayer.sessionTime(), so all players see the same water at the same moment
with nothing sent per frame, and a late joiner receives the fields and draws the water where it is
(a move that had already finished does not replay its splash). A call made on a peer that does not
write the volume's move is sent to the peer that does (multiplayer.send on floodKit:to), which starts the move a
quarter second ahead so every peer has it before it begins. With no session (edit, single
player) each call acts at once. Sounds, effects and the player hooks are local to each peer.
Put the volume on a synced entity (entity.spawnSynced); on a plain entity each peer keeps its own
water.
Cost
The water moves on Tidewater's setLevel: the drawn surface follows in 2 mm steps (a transform
write) and the physics water is re-declared in the tide's 2 cm steps. A volume ticks every frame
only while its water moves and five times a second otherwise; effects run at 15 Hz. Measured in
the showcase with all seven basins moving at once: 0.6 to 0.8 ms of script time a frame for all of
them together.
The showcase
This world's main scene: seven sunken concrete basins side by side on one walkway, one for each
style, each with a sign, a console button (walk up and press E), stairs down into the water and
the inlet that suits it (a feed pipe, a culvert, a sluice gate, weeping cracks, a floor drain, a
side spout, a tide gauge). First person.
Tests
floodKit.tests.floodKit (run zero tests run floodKit in edit): each style reaches its level in
time, tidal swings and stops, onReached fires once, depthAt, drain then fill, the synced move shape
and adopting a move another peer wrote, the curves' ends, who writes the move (the host for a
scene-owned synced volume, its owner otherwise, requests forwarded from every other peer), and no
errors with zero players. 15 tests.
Depends on
- Tidewater 1.2.22 (
tidewater): the water, andhandle:setLevel, which this package added to Tidewater (Tidewater pull request #16). 1.2.16 and later draw the view under the water on the current engine. - Tidewater FX 1.1.10 (
tidewaterFx, comes inside the Tidewater install, not a separate dependency): foam, ripples, drips, splashes. - Optional, never required: SecondWind (drowning damage), scriptedEventsKit (the
floodbeat), tidewaterSwim (swimming instead of wading).
Guides inside
- How to make water rise and drain on cue (flooding rooms, filling pools, draining a reservoir)
- Example: a corridor that floods behind the player
Versions
Version 1.0.4.
-
1.0.4 (2026-12-01): depends on Tidewater 1.2.22 (Tidewater FX 1.1.11 inside it). Tidewater FX's spindrift spray, which a surge plays, now takes the cross-wind as inputs instead of doing Luau maths on them, so the spray stays on the GPU and a rate change no longer re-cooks the whole graph on the CPU (in Low Water's finale that was a 2 to 5 ms task a frame on desktop and 12 to 24 ms in the browser). A game installing floodKit no longer carries a second, older Tidewater. No change to floodKit's own code.
-
1.0.3 (2026-11-30): a surge no longer floods the frame with ripple rings. Each surface ripple still goes into Tidewater's GPU ripple field at the style's rate, but the ring of foam particles Tidewater FX plays for a big ripple (a whole effect play lasting about 2.3 s, four kept warm) is started at most every 0.6 s. A surge asked for six or seven a second, so new ring plays were built on the spot all the time: in Low Water's finale that was about half the frame (engine CPU 71 to 38 ms with the flood's effects off). Same styles, sounds, foam, spray and field rings. Depends on Tidewater 1.2.19 alone: Tidewater FX 1.1.10 comes inside the Tidewater install, and a separate tidewaterFx line made ZeroMind refuse every push of this package (TREE_NOT_REPRODUCED).
-
1.0.2 (2026-11-28): depends on Tidewater 1.2.18 and Tidewater FX 1.1.10. The Tidewater 1.2.14 it named before failed to compile its underwater shader on current engines ("Requires 3 arguments, but 4 are provided"), so going under a flood showed the plain scene; with 1.2.18 the underwater look draws again. No change to floodKit's own code.
-
1.0.1 (2026-11-27): a scene-placed volume now moves in play. A scene's synced entity has no owner in play (
isLocal()is false even on the host), so 1.0.0 accepted Flood.to and moved nothing; the host now writes the move for a volume no peer owns, the owner for one a peer owns, and every other peer forwards its request. Newmodules/authorityholds the rule; 2 new tests (15 in all). -
1.0.0 (2026-11-27): first release. FloodVolume with seven styles, FloodSwitch, the API, wading and drowning hooks, scriptedEventsKit beat, sounds for every style, synced moves with late join, the seven-basin showcase, 13 tests.