RLS Studios
ProjectsPatreonCommunityDocsAbout
Join Patreon
BeamNG Modding Docs

Guides

Reference

server/commands - Camera & Input Commandsge_utils - Game Engine Utility Functionsmain.lua - GE Lua Entry Point & Game Loopmap.lua - Navigation Graph (AI Road Map)screenshot.lua - Screenshot Systemserver/server - Level Loading & Game ServerserverConnection - Client-Server Connection Manager`setSpawnpoint` - Default Spawn Point Persistence`simTimeAuthority` - Simulation Time & Bullet Time Control`spawn` - Vehicle Spawning & Safe Placement`suspensionFrequencyTester` - Suspension Natural Frequency Analysis
Auto AnnotationBoosterCalibrate ESCCompile ImpostersCompile MeshesConfig List GeneratorDecal Roads EditorDependency TreeDoc CreatorExport (glTF)Follow The White RabbitForest GeneratorGround Model DebugInput System UtilsInstanced Line Render DemoJBeam StatsLog StreamsMap TilesNode Beam ExportNode StreamPhotomodePrecompile ShadersPrecompile VehiclesProcedural Track (Gymkhana Generator)Rectangle GeneratorRender Components APIResave MaterialsRich PresenceSave Dynamic DataScreenshot Creator (Vehicle Thumbnails)ShowroomSort LinesStep HandlerTerrain GeneratorTest Extension ProxiesTest JSON Files Syntaxutil/vehicleRopeDebug - Rope Physics Debug UIutil/worker - Batch Job Workerutil/wsTest - WebSocket Test Server

UI

Resources

BeamNG Game Engine Lua Cheat SheetGE Developer RecipesMCP Server Setup

// RLS.STUDIOS=true

Premium Mods for BeamNG.drive. Career systems, custom vehicles, and immersive gameplay experiences.

Index

HomeProjectsPatreon

Socials

DiscordPatreon (RLS)Patreon (Vehicles)

© 2026 RLS Studios. All rights reserved.

Modding since 2024

API ReferenceGE Extensionsutil

Forest Generator

Procedural forest generation utility for creating, querying, updating, and deleting forest items programmatically.

Procedural forest generation utility for creating, querying, updating, and deleting forest items programmatically.


Overview

util_forestGenerator wraps the engine's forest system to provide high-level functions for procedural vegetation placement. Supports creating single items, random rectangular/radial forests, querying items by polygon or radius, and clearing forests.

Extension path: lua/ge/extensions/util/forestGenerator.lua


Exports (M)

FunctionSignatureDescription
initForest()Initializes forest data and builds item type dictionary.
createForestItem(itemType, pos, rotDeg, scl)Creates a single forest item.
createRandomForestRect(itemTypeArray, amount, pos, minX, maxX, minY, maxY, rotSteps, minScl, maxScl)Creates random forest in a rectangle.
createRandomForestRadial(itemTypeArray, amount, pos, radius, rotSteps, minScl, maxScl)Creates random forest in a circle.
updateForestItem(item, pos, rotDeg, scl)Updates an existing forest item's transform.
getForestItemTypes()Returns sorted array of available item type names.
getForestItemDict()Returns dictionary of item type name → forest item template.
getForestItemsPolygon(polygon)Returns items within a polygon (or all items if nil).
getForestItemsRadius(pos, radius)Returns items within a radius (default: camera pos, 20 units).
deleteForestItem(item)Deletes a single forest item.
clearForest()Deletes all forest items except templates.

Internals

Initialization

initForest() is called on load and:

  1. Gets the forest object via core_forest.getForestObject():getData().
  2. Builds forestItemDict mapping internal names to item templates.
  3. Sorts type names into forestItemTypes.

Random Placement - Rectangle

createRandomForestRect() uses blue noise distribution:

  • Positions are generated via vec3:getBlueNoise2d() and lerped into bounds.
  • Rotation is discretized by rotSteps (default 360).
  • Scale is randomized between minScl (0.75) and maxScl (1.25).
  • Z-height is set from terrain height if available.

Random Placement - Radial

createRandomForestRadial() uses vec3:getRandomPointInCircle(radius):

  • Similar randomization for rotation and scale.
  • Terrain height snapping.

Clear Forest

clearForest() iterates all items and deletes any whose key differs from the template's key (preserving the template/base items).


How It Works

  1. Ensure a level is loaded with a Forest object.
  2. Call initForest() (auto-called on load).
  3. Use getForestItemTypes() to see available vegetation types.
  4. Call creation functions to place vegetation.
  5. Query with polygon/radius, update, or clear as needed.

Lua Examples

local fg = extensions.util_forestGenerator

-- List available forest item types
local types = fg.getForestItemTypes()
dump(types) -- {"oak_tree", "pine_tree", "bush_small", ...}

-- Create a single tree at position
fg.createForestItem("oak_tree", vec3(100, 200, 0), 45, 1.2)

-- Create 50 random trees in a 200x200 area
fg.createRandomForestRect({"oak_tree", "pine_tree"}, 50, vec3(0,0,0), -100, 100, -100, 100)

-- Create 30 random trees in a 50-unit radius circle
fg.createRandomForestRadial(nil, 30, vec3(100, 100, 0), 50)

-- Get items near camera
local nearby = fg.getForestItemsRadius(nil, 50)

-- Clear all generated items
fg.clearForest()

Additional Exports

  • M.clearForest - (undocumented)
  • M.createForestItem - (undocumented)
  • M.createRandomForestRadial - (undocumented)
  • M.createRandomForestRect - (undocumented)
  • M.deleteForestItem - (undocumented)
  • M.getForestItemDict - (undocumented)
  • M.getForestItemTypes - (undocumented)
  • M.getForestItemsPolygon - (undocumented)
  • M.getForestItemsRadius - (undocumented)
  • M.initForest - (undocumented)
  • M.updateForestItem - (undocumented)

Follow The White Rabbit

A minimal text-adventure easter egg that runs in a custom console context.

Ground Model Debug

ImGui-based debug tool for visualizing and editing ground model physics properties in real time.

On this page

OverviewExports (M)InternalsInitializationRandom Placement - RectangleRandom Placement - RadialClear ForestHow It WorksLua ExamplesAdditional Exports