Environment Classes

class TimeOfDay

class TimeOfDay : SceneObject
TimeOfDay()

Creates a new TimeOfDay-Object

Example:

local tod = TimeOfDay()
print(tod:__tostring())  -- Prints 0.0000
__tostring()
Returns:a LUA string in this format %f

Example:

local tod = TimeOfDay()
print(tod:__tostring())  -- Prints 0.0000

class LevelInfo

class LevelInfo : SceneObject
LevelInfo()

constructor

table getTemperatureCurveC()
Returns:a table with the Temperare Curve in float Celcius

Example

local info = LevelInfo()
local tab = info:getTemperatureCurveC()
for i, elem in pairs(tab) do
    if type(elem) == "table" then
        for i1, elems in pairs(elem) do
            print(i..","..i1..":"..elems)
        end
    else
        print(i..","..i1..":"..elem)
    end
end

Prints in Console:

51121.389|A|GELua.print|1,1:0
51121.390|A|GELua.print|1,2:15
51121.390|A|GELua.print|2,1:1
51121.391|A|GELua.print|2,2:15
setTemperatureCurveC(table temp)

set the Temperare Curve in float Celcius from the temp table

Parameters:

  • table temp: The Temperature Table you want to set

Example:

local tab = {{1, 16}, {2, 20}}
local levelInfo = LevelInfo()
levelInfo:setTemperatureCurveC(tab)
print(levelInfo:getTemperatureCurveC()[1][2]) -- prints 16

class Prefab

class Prefab : SceneObject
Prefab()

Creates a new Prefab Object

Example:

local prefab = Prefab()
prefab:load()
print(prefab:isLoaded())
load(bool interactive = false)

Parameters:

  • bool interactive: refresh Physic manager collision

Example:

local prefab = Prefab()
prefab:load()
print(prefab:isLoaded())
unload(bool interactive = false)

Parameters:

  • bool interactive: refresh Physic manager collision

Example:

local prefab = Prefab()
prefab:load()
prefab:unload()
print(prefab:isLoaded())
bool isLoaded()
Returns:true if the prefab is loaded, false otherwise

Example:

local prefab = Prefab()
prefab:load()
prefab:unload()
print(prefab:isLoaded())

class MissionMarker

class MissionMarker : SceneObject
MissionMarker()

Creates a new Missionmarker Object.

Example:

local missionmarker = MissionMarker()
print(missionmarker:getPosition()) -- prints 0,0,0, because we did not set the position

class ScatterSky

To the Main Thread: ScatterSky

class ScatterSky : SceneObject
ScatterSky()

Creates a new ScatterSky-Object

Example:

local sSky = ScatterSky() -- Creates a new ScatterSky-Object
local sSky = scenetree.findObject(6595) -- Gets the ScatterSky via its ID
-- You can get the ID by the Editor using Scene Tree
setAzimuth(float azimuth)

Sets the Azimuth of the ScatterSky. To get a definition See: getAzimuth()

Parameters:

  • float azimuth: The azimuth, you want to set to the ScatterSky

Example:

local sky = scenetree.findObject("sunsky")
sky:setAzimuth(100)
print(sky:getAzimuth()) -- prints 100
float getAzimuth()

Azimuth is an angular measurement used to locate an object, star, etc.: it is measured clockwise around the horizon from the north, or south, to the object or the intersection of the object’s vertical circle with the horizon

Returns:(float) The azimuth of the ScatterSky

Example:

local sky = scenetree.findObject("sunsky")
print(sky:getAzimuth()) -- prints f.e. 57.29577636

class CloudLayer

To the Main Thread: CloudLayer

class CloudLayer : SceneObject
CloudLayer()

To get the CloudLayer from the Map, just open the Editor and copy the name

Example:

local clouds = scenetree.findObject("clouds_1") -- To get the existing CloudLayer
local cloud = CloudLayer() -- To create a new CloudLayer-Object

class MissionMarker

class SpawnSphere : MissionMarker
SpawnSphere()

To get the SpawnnSphere from the map, just open the editor and copy the name

Example:

local spawnsphere = scenetree.findObject("spawn_default") -- To get the existing Spawnsphere
local spawnsphere = SpawnSphere() -- To create a new Spshepre-Object

class TSStatic

class TSStatic : SceneObject
TSStatic()

Creates a new TSStatic-Object

Example:

local static = TSStatic() -- Create a new TSStatic Object
local static = scenetree.findObject("8154") -- To get a static object via ID
playAnim(char sequenceName, bool loop)
table getAnim()

New in version 0.13.

return a table with information about the current animation playing

Returns:A table as bellow
Index Type Default
sequenceName String “NO ANIMATION”
sequenceId Number(Int) -1
sequenceTime Number(Float 0-1) -1

Note

if sequenceId or sequenceTime is equal to -1 the animation is not enabled on this object or the data cannot be retrived

Example:

local object1 = scenetree.findObject(5942)
local tab = object1:getAnim()
for i, elems in pairs(tab) do
    print(i..","..elems)
end

Prints in Console:

045.213|A|GELua.print|sequenceId,-1
045.214|A|GELua.print|sequenceName,NO ANIMATION
045.214|A|GELua.print|sequenceTime,-1

class Forest

To the Main Thread: Forest

class Forest : SceneObject
Forest()

Creates a new Forest Object

Example:

local forest = Forest() -- Create a new Forest-Object
local forest = scenetree.findObject("theForest") -- Gets the Forest via name
-- You get the name by the Editor at the Scene-Tree Level_Objects/vegetation

class WaterObject

class WaterObject : SceneObject
WaterObject()

constructor

class TerrainBlock

To the Main Thread: Terrainblock

class TerrainBlock : SceneObject
TerrainBlock()

Example:

local tblock = TerrainBlock() -- Create a new TerrainBlock-Object
local tblock = scenetree.findObject("port") -- Gets the TerrainBlock via name
-- You get the name by the Editor at the Scene-Tree Level_Objects/Other
float getHeight(Point3F pos)

Gets the Height of the Terrain at the Position pos

Returns:float the height of the terrain at pos

Example:

local tblock = scenetree.findObject("port")
print(tblock:getHeight(Point3F(0, 0, 0)))
float getWorldBlockSize()

Gets the Size of the World Block.

Returns:(float) The Size

Example:

local tblock = scenetree.findObject("port")
print(tblock:getWorldBlockSize()) -- prints f.e. 1024
float getSquareSize()

Gets the SquareSize of the TerrainBlock

Example:

local tblock = scenetree.findObject("port")
print(tblock:getSquareSize()) -- prints f.e. 1

class WaterBlock

To the Main Thread: Waterblock

class WaterBlock : WaterObject
WaterBlock()

Creates a new Waterblock

Example:

local water = WaterBlock() -- Creates a new WaterBlock
local tblock = scenetree.findObject("waterblock") -- Gets the WaterBlock via its name

class Precipitation

To the Main Thread: Precipitation

class Precipitation : GameBase

With this class you can controll the Weater / Rain

Precipitation()

Example:

local rain = Precipitation() -- Creates a new Precipitation-Object
local tblock = scenetree.findObject("crazy_rain") -- Gets the Precipitation via its name

class DecalRoad

To the Main Thread: DecalRoad

class DecalRoad : SceneObject
DecalRoad()

Creates a new DecalRoad-Object

Example:

local droad = DecalRoad() -- Creates a new DecalRoad-Object
local droad = scenetree.findObject(6962) -- Gets the DecalRoad via its ID
-- You can get the ID by the Editor using Scene Tree
int getNodeCount()
Returns:(int) Node-Count

Example:

local droad = scenetree.findObject(6962)
-- You can get the ID by the Editor using Scene Tree
print(droad:getNodeCount()) -- prints f.e. 11 the count of Nodes from the DecalRoad
Point3F getNodePosition(int idx)

Gets the Position of the Node with ID idx

Parameters

  • int idx: The Id you want to get the node-Width from
Returns:(Point3F) The Position of the Node

Example:

local droad = scenetree.findObject(6962)
-- You can get the ID by the Editor using Scene Tree
print(droad:getNodePosition(3)) -- prints f.e. 206.647, 66.1855, 42.5703 (Position of node with ID 3)
float getNodeWidth(int idx)

Gets the Widht of the node with id idx

Parameters

  • int idx: The Id you want to get the node-Width from

Example

local droad = scenetree.findObject(6962)
-- You can get the ID by the Editor using Scene Tree
print(droad:getNodeWidth(3)) -- prints f.e. 12
table getNodesTable()
Returns:(table) The nodes of the Decal Road

Example

local droad = scenetree.findObject(6962)
local tab = droad:getNodesTable()
for i, elem in pairs(tab) do
    if type(elem) == "table" then
        for i1, elem1 in pairs(elem) do
            print(i..","..i1..":"..tostring(elem1))
        end
    else
        print(i..","..elem)
    end
end

For a DecalRoad with 4 Nodes it prints in Console:

1,1:243.8, 96.4706, 43.6289
1,2:4
2,1:238.989, 82.1122, 42.3438
2,2:4
3,1:222.456, 72.1141, 41.2813
3,2:4
4,1:206.647, 66.1855, 42.5703
4,2:4

class LightBase

class LightBase : SceneObject
setLightEnabled(bool enabled)

Parameters:

  • bool enabled: true if Light should be enabled, false otherwise

Example:

local light = scenetree.findObject(6599)
-- light is a PointLight
-- You can get the ID by the Editor using Scene Tree
light:setLightEnabled(true)
print(light:getLightEnabled()) -- prints f.e. true
bool getLightEnabled()
Returns:(bool) true if light is enabled, false otherwise

Example:

local light = scenetree.findObject(6599)
-- light is a PointLight
-- You can get the ID by the Editor using Scene Tree
print(light:getLightEnabled()) -- prints f.e. true

class PointLight

To the Main Thread: PointLight

class PointLight : LightBase
PointLight()

Creates a new PointLight-Object

Example:

local light = PointLight() -- Creates a new PointLight-Object
local light = scenetree.findObject(6595) -- Gets the PointLight via its ID
-- You can get the ID by the Editor using Scene Tree

class SpotLight

To the Main Thread: SpotLight

class SpotLight : LightBase
SpotLight()

Creates a new SpotLight-Object

Example:

local light = SpotLight() -- Creates a new SpotLight-Object
local light = scenetree.findObject(6595) -- Gets the SpotLight via its ID
-- You can get the ID by the Editor using Scene Tree

class BeamNGPointOfInterest

class BeamNGPointOfInterest : SceneObject
BeamNGPointOfInterest()

Creates a new Point Of Interest-Object

Example:

local point = BeamNGPointOfInterest() -- Creates a new BeamNG Point Of Interest-Object
local point = scenetree.findObject(11997) -- Gets the BeamNGPointOfInterest via its ID
-- You can get the ID by the Editor using Scene Tree / f.e LUA Trigger

class BeamNGTrigger

class BeamNGTrigger : GameBase
BeamNGTrigger()

Creates a new BeamNGTrigger-Object

Example:

local trigger = BeamNGTrigger() -- Creates a new BeamNGTrigger-Object
local trigger = scenetree.findObject(6995) -- Gets the BeamNGTrigger via its ID
-- You can get the ID by the Editor using Scene Tree / f.e LUA Trigger
bool debug

Enable/disable debug of this trigger

Debug information include:

  • Permanenttly drawing the box which represent the size of the trigger
  • Displaying points that could activate the trigger (red: outside, green: contained)
  • Display a fuchsia box when the trigger is activated
local trigger = scenetree.findObject(24072) -- Gets the BeamNGTrigger via its ID
print(trigger.debug) -- prints "true"
ColorI color

Sets the color of the debug box

Note

Changes to this value are visible only if the flag BeamNGTrigger::debug is on

local trigger = scenetree.findObject(24072) -- Gets the BeamNGTrigger via its ID
print(trigger.debug) -- prints "true"
bool isPointContained(Point3F pt)

New in version 0.11.

Check if a point is contained in the trigger

Parameters:

  • Point3F pd: The point that should be checked if its contained in the box
Returns:(bool) true if the point is contained in the trigger, false otherwise

Example:

local trigger = scenetree.findObject(24072) -- Gets the BeamNGTrigger via its ID
local point = Point3F(200, 100, 100)
print(trigger:isPointContained(point)) -- prints "true" if its in the Box, false otherwise
class BeamNGWaypoint : SceneObject
BeamNGWaypoint()

Creates a new BeamNGWaypoint-Object

Example:

local wpoint = BeamNGWaypoint() -- Creates a new BeamNGWaypoint-Object
local wpoint = scenetree.findObject(6995) -- Gets the BeamNGWaypoint via its ID
-- You can get the ID by the Editor using Scene Tree / f.e LUA Trigger