(Solved) How to get ignitionState of vehicle?

Discussion in 'Programming' started by MegaKnight, Jan 24, 2025.

  1. MegaKnight

    MegaKnight
    Expand Collapse

    Joined:
    Sep 12, 2024
    Messages:
    218
    Does anyone know how to get the ignitionState of a vehicle from GE lua?

    I want to check if a vehicle inside a trigger has the ignition turned off. What functions would I have to use for that?

    I already know that this value is stored in electrics.values.ignitionLevel on vehicle lua side, but I haven't found a way to access this value from GE lua.

    Update: I was able to figure it out. I wrote two extensions, one for GE lua and one for vehicle lua. The vehicle lua extension is called from GE lua side and updates a value in the GE lua extension, which can then be accessed by GE lua.
     
    #1 MegaKnight, Jan 24, 2025
    Last edited: Jan 24, 2025
  2. DaddelZeit

    DaddelZeit
    Expand Collapse

    Joined:
    Jul 17, 2019
    Messages:
    3,473
    You can also use the core_vehicleBridge extension for this.
    Code:
    core_vehicleBridge.registerValueChangeNotification(vehicle, "ignitionLevel")
    Code:
    core_vehicleBridge.getCachedVehicleData(vehicleID, "ignitionLevel")
    Code:
    core_vehicleBridge.unregisterValueChangeNotification(vehicle, "ignitionLevel")
     
    • 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