Lightbar

Summary

The Lightbar controller can be used to implement custom lightbar flash patterns. Also allows the definition of multiple flashing modes that you’ll be able to cycle through.


File Info

Filename lightbar.lua
Path /lua/vehicle/controller/lightbar.lua
Type Auxiliary
Usage type Multiple

JBeam Properties

array
type
Array of lightbar modes that can be toggled.
See the lightbar mode section for more info on the different parameters available.
number
type
1
default
The default mode the lightbar starts with.


lightbarMode

string
type
Name of the lightbar mode.
array
type
Array of pattern data for this mode.
See the light mode pattern section for more info on the different parameters available.


lightbarModePattern

string
type
Name of electrics variable to control.
number
type
Value the electric is set to.
number
type
How long the value is being set before the next value for the specific electric is being set.


Public Functions

Function name
Parameters
Description
Function name
toggleMode()
Parameters
Description
Toggles between available lightbar modes

Example Usage

"controller": [
  ["fileName"],
  ["lightbar"]
],
"lightbar": {
  "defaultModeIndex": 1,
  "modes": [
    ["name", "config"]
    ["Left Signal", [
      ["electric", "value", "duration"],
      ["blue_3", 1, 1.0],
      ["blue_2", 0, 0.1],
      ["white_2", 0, 0.2],
      ["blue_1", 0, 0.3],
      ["red_1", 0, 0.4],
      ["white_1", 0, 0.5],
      ["red_2", 0, 0.6],
      ["red_3", 0, 0.7],

      ["blue_3", 0, 0.0],
      ["blue_2", 1, 0.9],
      ["white_2", 1, 0.8],
      ["blue_1", 1, 0.7],
      ["red_1", 1, 0.6],
      ["white_1", 1, 0.5],
      ["red_2", 1, 0.4],
      ["red_3", 1, 0.3],
      ],
    ],
    ["Right Signal", [
      ["electric", "value", "duration"],
      ["red_3", 1, 1.0],
      ["red_2", 0, 0.1],
      ["white_1", 0, 0.2],
      ["red_1", 0, 0.3],
      ["blue_1", 0, 0.4],
      ["white_2", 0, 0.5],
      ["blue_2", 0, 0.6],
      ["blue_3", 0, 0.7],

      ["red_3", 0, 0.0],
      ["red_2", 1, 0.9],
      ["white_1", 1, 0.8],
      ["red_1", 1, 0.7],
      ["blue_1", 1, 0.6],
      ["white_2", 1, 0.5],
      ["blue_2", 1, 0.4],
      ["blue_3", 1, 0.3],
      ],
    ],
  ],
}

Last modified: 16/1/2022 10:43

Any further questions?

Join our discord