local M = {} local ip = "127.0.0.1" local port = 4444 local udpSocket = nil local cbor = require("cbor"); local function sendPackage(ip, port, id) if not electrics.value.watertemp then -- vehicle not completly initialized, skip sending package return end local data = { app = "beamNG" } log("I", "ExtDash", "data: " .. tostring(data) ) end local function updateGFX(dt) if not playerInfo.firstPlayerSeated then return end end local function onExtensionLoaded() if not udpSocket then udpSocket = socket.udp() end ip = settings.getValue("outgaugeIP") port = tonumber(settings.getValue("outgaugePort")) log("I", "ExtDash", "Extension loaded, connecting to " .. tostring(ip) .. " (" .. tostring(port) .. ")" ) return true end local function onExtensionUnloaded() if udpSocket then udpSocket:close() end udpSocket = nil end -- public interface M.onExtensionLoaded = onExtensionLoaded M.onExtensionUnloaded = onExtensionUnloaded M.updateGFX = updateGFX -- other functions M.sendPackage = sendPackage return M