I want to have a choice of routes in my scenario so that when the player drives through path A, the waypoints now correspond to path A. Likewise, if the player goes through path B, the waypoints should correspond to path B. I noticed in the map editor under "Level" there is such a thing as "BeamNG Lua Trigger". However, I do not know when this is triggered and how to get it to call a function in the lua file. I assume it is triggered when a car drives through it similarly to how a waypoint works. Any help would be much appreciated.
Lua triggers calls a function named onBeamNGTrigger when a vehicle enters and when a vehicle leaves the trigger. ( or at least they do it then the luaFunction parameter is set to onBeamNGTrigger, like the lua triggers in the campaign scenarios ) You can then call custom actions using a code similar to the one used for waypoint trigger detection Code: local function onBeamNGTrigger(data) if data.parameter == 'parameterName' then doSomething() end end return { onBeamNGTrigger = onBeamNGTrigger, } The lua trigger's most useful parameters are : - event (parameterName ="enter" or "exit"), - triggerName (the name of the trigger), - subjectName ( "scenario_player0" for example)