How to get game variables out Beamng Drive into a programming environment?

Discussion in 'Programming' started by Teun, Mar 17, 2020.

Tags:
  1. Teun

    Teun
    Expand Collapse

    Joined:
    Sep 1, 2017
    Messages:
    1
    Hello,

    I have a question about getting game variables like RPM and wheel speed in a C# script or sending it out via a serial port. I would like to make a dashboard with from an Arduino, but the only thing I don't know is how to get variables like RPM out the game into a C#, C++, java script or something like that. I hope someone can help me.
     
  2. Palculator

    Palculator
    Expand Collapse
    Goose-typed

    Joined:
    May 24, 2018
    Messages:
    13
    Hi,

    the game ships with the luasocket library which you can use for interprocess communication. In both game engine and vehicle Lua you can import the socket library and open a connection. Another application listening on the other end can then send & receive data. To import the socket library:

    Code:
    local socket = require('libs/luasocket/socket.socket')
    From then on, the library mostly behaves like sockets from C. One caveat is that any blocking call in Lua also leads to the game halting, so read-calls to sockets with no data available would make the game hang until data is read. To avoid this, use the socket.select function described here or rely on the Copas library, which is also available in our Lua.
     
    • Informative Informative x 2
  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