Solved Using a value from javascript in a lua script

Discussion in 'Mod Support' started by HDR, Sep 1, 2018.

  1. HDR

    HDR
    Expand Collapse

    Joined:
    Oct 15, 2015
    Messages:
    258
    Just wondering if anyone has a clever solution for my issue, i'm currently running a lua script trough a ui app that has a slider.

    Code:
    bngApi.activeObjectLua( 'extensions.slowmoApp.setSlowmoPercentage()' );
    

    but i'm having issues trying to send the value from the slider in the javascript to the lua. (There is probably something really obvious that i overlooked)
     
    #1 HDR, Sep 1, 2018
    Last edited: Sep 1, 2018
    • Like Like x 1
  2. thomatoes50

    thomatoes50
    Expand Collapse
    BeamNG Team

    Joined:
    Jan 31, 2013
    Messages:
    722
    Code:
    bngApi.engineLua( 'extensions.slowmoApp.setSlowmoPercentage('+ slider.value.toString() + ')' );
    `activeObjectLua` is to send a command to the current vehicle

    i'm not sure what you are trying to do but most probably the module is in GE so you should use `engineLua`, if it was a vehicle extensions them `activeObjectLua` was correct
     
    • Like Like x 1
  3. HDR

    HDR
    Expand Collapse

    Joined:
    Oct 15, 2015
    Messages:
    258
    So in theory i wouldn't even need the custom lua if i'm calling the bullettime.lua in ge right?


    and just do it like this instead?
    Code:
    bngApi.engineLua( 'bullettime.set('+ val.toString() + ')' );
    
     
  4. thomatoes50

    thomatoes50
    Expand Collapse
    BeamNG Team

    Joined:
    Jan 31, 2013
    Messages:
    722
    yes this will work directly, the value need to be between 0.0 and 1.0
     
    • Like Like x 1
  5. HDR

    HDR
    Expand Collapse

    Joined:
    Oct 15, 2015
    Messages:
    258
    Got it working now, thank you :)
     
  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