WaterBody.component
This package holds more than this page lists. See all of its files in its world.
README.md
WaterBody
Any kind of Tidewater water, saved with the scene. Two fields decide what it is:
kind(11 kinds): ocean, shoreline, lake, pond, pool, hotspring, river, stream, waterfall, puddles, underwaterlook(7 looks): realistic, crystal, painted, cartoon, lowpoly, pixel, toy (glossy plastic for toy-style games)
Change either and the water rebuilds in place. preset picks a named variety of that kind
(empty = its default). The rest are the shape: size (x, z metres) and depth for lakes,
ponds, pools and puddle areas; path (points "x,y,z; x,y,z; ...", in the entity's space) and
width for rivers, streams and waterfalls (a waterfall's path runs from the lip down to the
pool); tide (metres, low to high water, 0 = none) and tidePeriod (seconds, default 600) give an ocean, shoreline or lake a tide on the shared water clock; quality (auto, low, medium, high, ultra) sets how finely it is resolved; options takes any kind-specific override as JSON. Its full name is tidewater.components.WaterBody.
The entity's transform places the water. The fields replicate, every peer builds the same water from them, and the waves run on the shared water clock, so every player sees the same surface.
local e = entity.spawnSynced("Lake", { position = { 0, 2, 0 } })
e.component.add("tidewater.components.WaterBody", { kind = "lake", look = "realistic", size = { 60, 40 }, depth = 6 })
e.component.get("tidewater.components.WaterBody").look = "cartoon" -- same lake, cartoon
e.component.get("tidewater.components.WaterBody").kind = "pond" -- now a pond
e.component.get("tidewater.components.WaterBody"):heightAt(5, 3) -- this water's own surface there, nil off it (never another water)
heightAt(x, z) and flowAt(x, z) answer for this body of water alone, even where another
water lies above or below it. To ask for whatever water is on top at a spot, use
Water.heightAt(x, z) from tidewater.modules.water.