1. Stuck, Having problems with creating your mod? Let us help you: Mod Support

Solved Switch ESC config from vehicle Lua?

Discussion in 'Mod Support' started by aljowen, Feb 11, 2019.

  1. aljowen

    aljowen
    Expand Collapse

    Joined:
    Oct 21, 2012
    Messages:
    1,498
    Is it possible to switch the ESC config from within vehicle Lua?

    For example, switch from mode '0' to mode '1', as defined in the jbeam (normal, sport, off).

    Thanks :)
     
  2. meywue

    meywue
    Expand Collapse
    BeamNG.QA
    Staff Member

    Joined:
    Nov 19, 2015
    Messages:
    314
    Something like this in vehicle lua should work™:

    Code:
    local esc = controller.getController('esc')
    if esc then
        esc.toggleESCMode()
    end
    or use..

    Code:
    esc.setESCMode(x)
    Where x can be 2,3 or 4.

    2 => Sport ESC
    3 => No ESC
    4 => Regular ESC
     
    #2 meywue, Feb 12, 2019
    Last edited: Feb 12, 2019
    • Informative Informative x 1
  3. aljowen

    aljowen
    Expand Collapse

    Joined:
    Oct 21, 2012
    Messages:
    1,498
    Thanks, worked perfectly :)
     
    • Like Like x 1
  4. Diamondback

    Diamondback
    Expand Collapse
    Moderator
    Staff Member

    Joined:
    Apr 8, 2014
    Messages:
    1,154
    Please note that the mode index is not something set in stone, it depends on the order of modes in the jbeam. So while with our stock content 1 usually ends up being regular, there is no guarantee for that.
     
    • Informative Informative x 2
  5. aljowen

    aljowen
    Expand Collapse

    Joined:
    Oct 21, 2012
    Messages:
    1,498
    Thanks for that clarification.

    In my specific use case it should be fine, since its for the dashboard system of a custom vehicle, so providing I don't reorder the ESC in the jbeam, it shouldn't be an issue. But good to know regardless :)
     
  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