Lightbar

Summary

The Lightbar controller can be used to implement custom lightbar flash patterns. Different modes can be defined that can be toggled through.

File Info

Filename lightbar.lua
Path /lua/vehicle/controller/lightbar.lua
Multiple Usage Supported

Jbeam Properties

Name Default Unit Description
modes nil array<lightbarMode> Array of lightbar modes that can be toggled
defaultModeIndex 1 number The default mode the lightbar starts with

lightbarMode

Name Default Unit Description
name nil string Name of the lightbar mode
config nil array<lightbarModePattern> Array of pattern data for this mode

lightbarModePattern

Name Default Unit Description
electric nil string Name of electrics variable to control
value nil number Value the electric is set to
duration nil number How long the value is being set before the next value for the specific electric is being set

Public functions

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

Example Usage

Controller setup

"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],
      ],
    ],
  ],
}