[SOLVED]How to import a tuning value from jbeam to lua?

Discussion in 'Mod Support' started by S.Ali.M, Jun 14, 2021.

  1. S.Ali.M

    S.Ali.M
    Expand Collapse

    Joined:
    Jan 12, 2021
    Messages:
    1,080
    Hello!
    Here's what I did and not working:
    Jbeam:
    Inkedbandicam2021-06-1412-49-00-652_LI.jpg

    Lua:
    Inkedbandicam2021-06-1412-49-15-880_LI.jpg

    Thanks in advance!
    Edit: jbeam works. My lua file is broken

    P.S: I know those names are horrible. Don't tell me "Why sensitivity of alarm called strength?"
     
  2. Agent_Y

    Agent_Y
    Expand Collapse

    Joined:
    Jul 10, 2020
    Messages:
    7,155
    I don't think it will work if you leave it in Jbeam outside of any section, the way I always get this to work is by making the LUA file a controller and making a new section for the controller where I put all the variables like this:
    asdasdasdasd.png
    And in the LUA it's like this:
    sfdxczc.png
    The "or" is for a rare case when the Jbeam would not load properly for some reason, like if someone made a mod that overrides this one.
     
  3. S.Ali.M

    S.Ali.M
    Expand Collapse

    Joined:
    Jan 12, 2021
    Messages:
    1,080
    Thanks. I'll try it
    Btw, now my lua is in VEHICLENAME/lua. After doing these, I should move it to VEHICLENAME/lua/controller, right?
     
  4. Agent_Y

    Agent_Y
    Expand Collapse

    Joined:
    Jul 10, 2020
    Messages:
    7,155
    Yeah and you should change all the stuff that makes the file work as a controller, I forgot what it is exactly, check how it's done in official cars
     
  5. S.Ali.M

    S.Ali.M
    Expand Collapse

    Joined:
    Jan 12, 2021
    Messages:
    1,080
    OK. Thanks
     
  6. angelo234

    angelo234
    Expand Collapse
    Junior Programmer
    BeamNG Team

    Joined:
    Aug 11, 2017
    Messages:
    433
    You can actually access the "variables" JBeam section with just this Lua command:
    Code:
    v.data.variables["$alarmstrength"].val
     
    • Like Like x 4
  7. Agent_Y

    Agent_Y
    Expand Collapse

    Joined:
    Jul 10, 2020
    Messages:
    7,155
    That's really useful, cool
     
  8. S.Ali.M

    S.Ali.M
    Expand Collapse

    Joined:
    Jan 12, 2021
    Messages:
    1,080
    I wish I could rate your post like 100 times!
    Big thanks!
     
    • 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