Solved Set Throttle with JS (Ui-App)

Discussion in 'Mod Support' started by Neo, May 29, 2017.

  1. Neo

    Neo
    Expand Collapse

    Joined:
    Oct 31, 2015
    Messages:
    260
    Hello Community,
    is there a way to set the throttle level with Javascript (not for holding a constant speed rather for holding a constant rpm)? I´ve already looked into the cruise control app, but they use a custom lua extension (I guess) and I don´t understand how to create my own (if neccessary).

    excerpt out of the "app.js" file at path /..\BeamNG.drive\ui\modules\apps\CruiseControl, line 40:
    Code:
    bngApi.activeObjectLua('extensions.use("cruiseControl").holdCurrentSpeed()');
    I appreciate all hints.

    And if it possible to send lua commands directly to the "vehicle lua"-engine via "bngApi.engineLua();" ?
    Then I could use somethink like
    Code:
    bngApi.engineLua('input.event("throttle", 0.5)');
     
    #1 Neo, May 29, 2017
    Last edited: May 30, 2017
  2. StinchinStein

    StinchinStein
    Expand Collapse

    Joined:
    Jul 16, 2014
    Messages:
    754
    Code:
    bngApi.activeObjectLua('input.event("throttle", 0.5)');
    Should work, have you tried it?

    I'm not a pro when it comes to BeamNG's UI System, but I think the "activeObjectLua" part is equal to the vehicle lua, correct me if I'm wrong.

    If that doesn't work, try this?
    Code:
    bngApi.engineLua("be:getPlayerVehicle(0):queueLuaCommand('input.event(\"throttle\", 0.5)')")
     
    #2 StinchinStein, May 31, 2017
    Last edited: May 31, 2017
    • Like Like x 1
    • Informative Informative x 1
  3. Neo

    Neo
    Expand Collapse

    Joined:
    Oct 31, 2015
    Messages:
    260
    That works:)

    Edit:
    Works too

    Thank you @StinchinStein
     
    #3 Neo, May 31, 2017
    Last edited: May 31, 2017
    • 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