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

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:
    233
    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
  2. thomatoes50

    thomatoes50
    Expand Collapse
    Staff Member

    Joined:
    Jan 31, 2013
    Messages:
    606
    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:
    233
    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
    Staff Member

    Joined:
    Jan 31, 2013
    Messages:
    606
    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:
    233
    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