Changing lightbar mode in Lua

Discussion in 'Programming' started by MarckyMON, Apr 4, 2025.

  1. MarckyMON

    MarckyMON
    Expand Collapse

    Joined:
    Dec 24, 2013
    Messages:
    10
    Hello,

    I would like to be able to change the lightbar mode (chase, takedown, and so on) from Lua. Unfortunately, the only thing I found so far (in vehicle VM) is electrics.set_lightbar_state(..).
    After going through the Lua code, I've noticed that in \lua\vehicle\controller\lightbar.lua, there is a function called setModeIndex, but I cannot figure out how to access it from either the GE VM or vehicle VM.

    If anyone could point me to the right direction, I would greatly appreciate it. Thanks!
     
  2. Feche

    Feche
    Expand Collapse

    Joined:
    Mar 15, 2025
    Messages:
    4
    Code:
    local lightbar = controller.getController("lightbar_rear")
    lightbar.setModeIndex(1)
    
    This works only in VE
     
    • Like Like x 1
  3. MarckyMON

    MarckyMON
    Expand Collapse

    Joined:
    Dec 24, 2013
    Messages:
    10
    Thanks! Though, in my case, I had to call
    Code:
    controller.getController("lightbar")
    to get the modes to switch.
     
    • Like Like x 1
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice