Accessing "siren" on/off

Discussion in 'Utilities and programming' started by yocal, Mar 9, 2024.

  1. yocal

    yocal
    Expand Collapse

    Joined:
    Mar 9, 2024
    Messages:
    1
    Hello,

    My kid loves to drive in police cars and firetrucks in BeamNG. The sirens are on 90% of the time, so I want to add some sirens to light up his simrig that also turns on once he turns on the ones in the game.

    Question is - how do I get started.

    The telemetry API doesn't seem to have this data (not surprised), but I wonder if the game exposes something like that in another API that I haven't found yet.

    If someone could just point me in the right direction, I'm sure I can figure out the details pretty easily.

    Thanks!
     
  2. daniel-w

    daniel-w
    Expand Collapse
    BeamNG Team

    Joined:
    Jan 28, 2017
    Messages:
    282
    Sure, if you just need to know where to look, then look at lua/vehicle/extensions/outgauge.lua, it will give you a basic idea of how the socket library works.
    You can get the lightbar state via electrics.values.lightbar.
    0 = Off
    1 = Lights on
    2 = Lights & Sirens on

    And to make life simpler, instead of sending a C structure over, you can just send some text like "0", "1" or "2". Those just indicate the above. Or if you send more data in the future, you could do something like "0:1", 0 meaning it's a lightbar operation, the colon is just a separator, and then the 1 is the lightbar state. Keeps it simple.

    With this, you can make a basic vehicle lua mod that sends the lightbar state whenever it changes.
    On the receiver end, you can use any language you want. C, C++, Python, etc...

    If you want, I could setup a basic template vehicle mod so you can use that. Just let me know :)
     
  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