Skip to content

setFoliageDensity

Client-side

Available in Neon, not standard MTA

Changes how thickly a foliage patch grows, rebuilding the native triangle.

Syntax

bool setFoliageDensity(foliage theFoliage, float density)

Arguments

theFoliagefoliage

Foliage element.

densityfloat

Multiplier from 0.0 through 10.0, where 1.0 is the native density for that surface.

Returns

true when the density was accepted and the patch rebuilt; false for a negative, above-10, or non-finite value.

Ownership and lifecycle

A foliage element belongs to the resource that created it and joins its element group, so stopping the resource removes its patches without explicit cleanup. Every setter rebuilds the native triangle atomically and rolls back to the previous state when the new combination is rejected.

Important behavior
  • 0.0 empties the patch while keeping the element alive.
  • The rebuild is atomic: a rejected density leaves the previous one in place.

OOP aliases

  • foliage:setDensity(density)
  • foliage.density

Where this comes from

RELATED NEON APIS

Continue exploring

Read the system guide →