Toggling electrics-related stuff with a trigger

Discussion in 'Programming' started by SSRG, Jan 25, 2024.

  1. SSRG

    SSRG
    Expand Collapse

    Joined:
    Jun 17, 2023
    Messages:
    4,338
    Hi!
    How would it be possible to toggle states related to electrics using triggers on vehicles, like the blue-green clickable ones? I know how to place a trigger and I know about trigger-event links and events, but not how to make the stuff toggle electrics.
    Specifically toggle these 3 things:
    - Left signal
    - Right signal
    - Parking brake

    I tried seeing how the RUSH does the hazard and lowhighbeam switches, but I didn’t get much from that at all.

    Oh, and also I have never worked with Lua before and have no clue how it works and how the syntax looks etc (other than from seeing that lua file i talked about earlier ofc). might be a minor inconvenience lol
     
  2. SineMatic

    SineMatic
    Expand Collapse

    Joined:
    Nov 17, 2022
    Messages:
    62
    I've made a simple mod for the default D-Series (see attached file). It is a trigger box placed above the hood, which toggles left turn signal when you click it. To make it appear, select "Trigger Left Signal" part in the "Tow hitch" slot (I've chosen this slot because it's empty by default).

    In fact, you don't need any custom Lua code to trigger the common vehicle actions. You can check the complete list of these in the file with C:\Program Files (x86)\Steam\steamapps\common\BeamNG.drive\lua\ge\extensions\core\input\actions\vehicle.json directory. Each listed action calls a certain Lua function in files with C:\Program Files (x86)\Steam\steamapps\common\BeamNG.drive\lua directory.

    If you want to create a custom action, you need to make a custom lua module (https://www.beamng.com/threads/binding-help.71172/ this thread might be useful)
     

    Attached Files:

    • Like Like x 1
  3. SSRG

    SSRG
    Expand Collapse

    Joined:
    Jun 17, 2023
    Messages:
    4,338
    Thanks! I’ll check this out when I can :D
     
  4. UN1T

    UN1T
    Expand Collapse

    Joined:
    Dec 23, 2023
    Messages:
    50
    These are all the electrics functions you can use:
    Code:
    updateGFX()
    updateGFXSecondStep()
    toggle_left_signal()
    toggle_right_signal()
    stop_turn_signal()
    set_warn_signal()
    toggle_lightbar_signal()
    set_lightbar_signal()
    toggle_fog_lights()
    set_fog_lights()
    toggle_lights()
    light_flash_highbeams()
    setLightsState()
    horn()
    setIgnitionLevel()
    toggleIgnitionLevelOnDown()
    toggleIgnitionLevelOnUp()
    setAllowedIgnitionLevels()
    initLastStage()
    reset()
    init()
    initLastStage()
    Values:
    Code:
    throttle
    brake
    steering
    clutch
    wheelspeed
    odometer
    avgWheelAV
    airspeed
    horn
    rpmspin
    rpm
    boost
    boostMax
    A simple example:
    Code:
    "events":[
            ["id", "title", "desc"],
            ["hazard", "",  "",  {"onDown"  :"electrics.toggle_warn_signal()"}],
        ],
     
    #4 UN1T, Apr 7, 2024
    Last edited: Apr 7, 2024
    • 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