Unsolved hardware information in lua

Discussion in 'Mod Support' started by fillman86, Jan 22, 2024.

  1. fillman86

    fillman86
    Expand Collapse

    Joined:
    Apr 18, 2020
    Messages:
    208
    I'm wanting to do a custom ui app that shows temps and fan speeds like a speedo, but my lua skill is limited, is it possible to get that information in lua? Is there documentation for this kind of data requisition in beamng? Is lua the wrong language (I'm not really good with coding)?
     
  2. daniel-w

    daniel-w
    Expand Collapse
    BeamNG Team

    Joined:
    Jan 28, 2017
    Messages:
    284
    There's no real documentation, but there are the game scripts you can look at. It's how we all do it, whether it's for Lua or Javascript, the code is the documentation.

    With the UI, you're really just best off looking at some of the code in "ui/modules/apps", you might find it easier.

    For example, in "ui/modules/apps/VehicleVicinity/app.js", you can see this line: "$scope.$on('onVehicleVicinityData', function (event, data)". If you search for "onVehicleVicinityData", you will find this in Lua:
    Code:
    guihooks.trigger('onVehicleVicinityData', data)
    
    That's calling the function we previously saw in Javascript.


    To get your fan speed and temps in-game, you'll want to use another language. Python should do the trick, though I would personally choose C++ just because I'm used to it.

    You can search for "socket.udp" in the game's Lua and there's many places you can see how it's used.
    The repository is located here: lunarmodules/luasocket at v3.1.0 (github.com)

    You'll want to make a regular Lua extension (let me know if you need help with that) and have it connect to your Python socket, once connected, it can then start calling "receive" to get the data (you'll have to send it in Python).

    If you don't know much, you might want someone else to do this for you because there's a lot of learning (learning Python, getting temps and fan speed (there's probably a decent library for that), getting the sockets in Python and in-game connected, etc...)

    Like I said though, spend some time looking at the game's Lua and JS. I'm very familiar with all of it now. When I first started with the UI side of things, it was not fun. Especially debugging, it was the worst lol. I know how to work with it all now though, and you will as well if you spend some time with it. I've spent a long time modding and messing about with this game, very fun :)

    Anyways, let me know if you need anymore help with anything, or maybe some examples
     
  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