api.module
README.md
api (module)
Start a field of drifting ambient particles from code and control it while it plays, for gameplay moments and film cues ("start the petals", "raise the fireflies").
local Drift = require("ambientDrift.api")
local f = Drift.start("fireflies", { position = vector.create(4, 0, -2), density = 0, quality = "auto" })
f:fadeTo(1, 6) -- raise the fireflies over 6 s
f:setStyleParams({ mood = "windy" }, 2) -- cross-fade to a windier field
f:setStyleParams({ tint = "#9fffd0", tintAmount = 0.5 })
print(f:get().count, f:get().tier)
f:stop(3)
start(style, opts)returns a handle. Options:root(entity to stand on and follow) orposition,area = { x, y, z },density,windDirection,windStrength,mood,tint,tintAmount,follow,quality,seed,sizeScale,fadeIn.- Handle:
fadeTo(density, seconds),setStyleParams(params, seconds),stop(seconds),get(),play()(the effect play, whoseplayback()reports cost). forEntity(e)returns the live field aDriftcomponent plays one.styles(),count(style, quality),autoTier().
A field started here belongs to the peer that starts it; the Drift component is the shared,
synced way. Called by the Drift component and by any script or cutscene.