Solved Send a value from lua to javascript

Discussion in 'Mod Support' started by jojos38, Jul 13, 2017.

  1. jojos38

    jojos38
    Expand Collapse

    Joined:
    Oct 22, 2013
    Messages:
    1,059
    Hi, how can i pass a value from JavaScript to lua please ? I tried much thing like use streams but i don't unsterstand how to send my value in a stream

    Thanks
     
    #1 jojos38, Jul 13, 2017
    Last edited: Jul 14, 2017
  2. aljowen

    aljowen
    Expand Collapse

    Joined:
    Oct 21, 2012
    Messages:
    1,677
    In your Lua:

    To create the html texture:
    Code:
    htmlTexture.create("textureName", "local://local/vehicles/fileName.html", textureWidthPixles, textureHeightPixels, updateSpeedInFPS, 'automatic')
    Make sure to leave the automatic parameter alone. The update speed may or may not be broken, I think it is stuck at 30fps currently.

    Then you can call the JavaScript like this:
    Code:
    htmlTexture.call("textureName", "functionName", parameter)
    If you want to pass multiple things then you need to pass "{value1 == value1, value2 == value2}" and so on.
     
    #2 aljowen, Jul 13, 2017
    Last edited: Jul 13, 2017
  3. jojos38

    jojos38
    Expand Collapse

    Joined:
    Oct 22, 2013
    Messages:
    1,059
    No i don't want to do html texture, i want to modify the text of the button. But it doesn't seem to be possible from lua, so i made it from javascript, but i need a value that it in the lua :/

    document.getElementById("THE BUTTON ID").textContent="HERE I WANT TO HAVE A LUA VALUE";
    But this line is runned in Javascript
     
  4. aljowen

    aljowen
    Expand Collapse

    Joined:
    Oct 21, 2012
    Messages:
    1,677
    Ah, ok, my bad, I thought you were on about vehicle Lua/Javascript.

    With vehicles there is no way to return a value from the JavaScript to the Lua. But this may be different with Apps, I have no idea. Hopefully someone else can jump in and give you a proper solution :)
     
  5. jojos38

    jojos38
    Expand Collapse

    Joined:
    Oct 22, 2013
    Messages:
    1,059
    Ok thank you
     
  6. jojos38

    jojos38
    Expand Collapse

    Joined:
    Oct 22, 2013
    Messages:
    1,059
    up
    --- Post updated ---
    This work:
    bngApi.engineLua(
    be:executeJS(\'document.getElementById("YOURBUTTONID").textContent= " \'.. YOUR VLUA VALUE .. \'" \')
    )
     
    • 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