Skip to content

Commit 28f21d9

Browse files
committed
Version 1.0.17
New car script : RSS GTM Macca 72 Evo V8 App improvements
1 parent 359c0db commit 28f21d9

File tree

5 files changed

+83
-10
lines changed

5 files changed

+83
-10
lines changed

Assetto Corsa/apps/lua/SimHubUDPConnector/SimHubUDPConnector.lua

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ local loadedExtensions = {}
3737
local loadedHightPriorityExtensions = {}
3838
local repoVersion = "0.0.0"
3939
local updatingApp = false
40-
local highPriorityExtensions = {"RoadRumbleExtension", "CollisionsExtension", "MirrorExtension"}
40+
local highPriorityExtensions = {"RoadRumbleExtension", "CollisionsExtension"}
4141
local jsonBuffer = {}
4242
local ROUNDING = 3
4343
local MULT = 10 ^ ROUNDING
@@ -178,12 +178,14 @@ end
178178
local function loadExtensions()
179179
-- Scan for new extensions.
180180
io.scanDir(ac.dirname() .. "/extensions", function(fileName, fileAttributes, callbackData)
181-
local extName = fileName:replace(".lua", "")
182-
if extName ~= "Extension" and extName ~= "SampleUserExtension" and not table.contains(obsoleteExtensions, extName) then
183-
if ExtensionsSettingsLayout[extName] == nil then
184-
ExtensionsSettingsLayout[extName] = false
181+
if fileName:endsWith("Extension.lua") then
182+
local extName = fileName:replace(".lua", "")
183+
if extName ~= "Extension" and extName ~= "SampleUserExtension" and not table.contains(obsoleteExtensions, extName) then
184+
if ExtensionsSettingsLayout[extName] == nil then
185+
ExtensionsSettingsLayout[extName] = false
186+
end
187+
detectedExtensions[#detectedExtensions + 1] = extName
185188
end
186-
detectedExtensions[#detectedExtensions + 1] = extName
187189
end
188190
end)
189191
ExtensionsSettings = ac.storage(ExtensionsSettingsLayout)
@@ -339,6 +341,24 @@ local function fastDataChanged(a, b)
339341
return false
340342
end
341343

344+
local function disposeExtension(extension)
345+
if extension and extension.dispose then
346+
try(function ()
347+
extension:dispose()
348+
end)
349+
end
350+
end
351+
352+
local function drawExtensionSettingsTab(extension)
353+
if extension and extension.drawSettingsTab then
354+
try(function ()
355+
extension:drawSettingsTab()
356+
end, function (err)
357+
print("Extension settings tab generated an error : " .. err)
358+
end)
359+
end
360+
end
361+
342362
function script.update(dt)
343363
slowUpdateTimer = slowUpdateTimer + dt
344364
if slowUpdateTimer < slowUpdateRate then return end
@@ -393,6 +413,9 @@ function script.updateHighPriority(dt)
393413
if fastDataChanged(customFastData, lastFastData) then
394414
udp:send(ultraJSON(customFastData))
395415
lastFastData = table.clone(customFastData)
416+
if debugOn then
417+
debugData(customFastData)
418+
end
396419
end
397420
end
398421

@@ -408,7 +431,7 @@ function script.windowMain(dt)
408431
ui.newLine()
409432
return
410433
end
411-
ui.tabBar('someTabBarID', function()
434+
ui.tabBar('simhubUDPConnectorTabBarID', function()
412435
ui.tabItem('Extensions', function()
413436
for _, extName in pairs(detectedExtensions) do
414437
local value = ExtensionsSettings[extName]
@@ -427,10 +450,13 @@ function script.windowMain(dt)
427450
end
428451
else
429452
if table.contains(highPriorityExtensions, extName) then
453+
disposeExtension(loadedHightPriorityExtensions[extName])
430454
loadedHightPriorityExtensions[extName] = nil
431455
else
456+
disposeExtension(loadedExtensions[extName])
432457
loadedExtensions[extName] = nil
433458
end
459+
package.loaded["extensions." .. extName] = nil
434460
end
435461
end
436462
end
@@ -485,5 +511,8 @@ function script.windowMain(dt)
485511
end
486512
end
487513
end)
514+
for _, ext in pairs(loadedExtensions) do
515+
drawExtensionSettingsTab(ext)
516+
end
488517
end)
489518
end
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
local SIM = ac.getSim()
2+
local CAR = ac.getCar(0)
3+
local FuelBase = CAR.fuel
4+
local LastFuel = CAR.fuel
5+
6+
local connection = {}
7+
local carId = ac.getCarID(0)
8+
local Ignition_RSS = ac.connect({
9+
ac.StructItem.key(carId .. "_Ignition" .. "_" .. 0),
10+
Mode = ac.StructItem.int32()
11+
}, true, ac.SharedNamespace.Shared)
12+
13+
local GTMSystemKey = carId .. "_GTMSystem"
14+
local ConnectsharedData = {
15+
ac.StructItem.key(GTMSystemKey .. "_" .. 0),
16+
AutoKill = ac.StructItem.boolean(),
17+
AntiStall = ac.StructItem.boolean(),
18+
AutoStart = ac.StructItem.boolean(),
19+
ThrottleMap = ac.StructItem.int32(),
20+
EngineStarter = ac.StructItem.boolean(),
21+
PopupTime = ac.StructItem.float(),
22+
PitLimitSpeed = ac.StructItem.int32(),
23+
LaunchControl = ac.StructItem.boolean(),
24+
ICERunning = ac.StructItem.boolean(),
25+
AirJackPos = ac.StructItem.float()
26+
}
27+
local GTMSystem = ac.connect(ConnectsharedData, true, ac.SharedNamespace.Shared)
28+
29+
function script.FuelUsed()
30+
if SIM.isInMainMenu or LastFuel < CAR.fuel then
31+
FuelBase = CAR.fuel
32+
end
33+
34+
LastFuel = CAR.fuel
35+
return FuelBase - CAR.fuel
36+
end
37+
38+
function connection:carScript(customData)
39+
customData.IgnitionMode = Ignition_RSS.Mode
40+
customData.FuelUsed = script.FuelUsed()
41+
addCarData(GTMSystem, ConnectsharedData, 'GTMSystem_', customData)
42+
end
43+
44+
return connection

Assetto Corsa/apps/lua/SimHubUDPConnector/extensions/DRIFTStatsExtension.lua

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

Assetto Corsa/apps/lua/SimHubUDPConnector/extensions/TrafficLighsExtension.lua

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

Assetto Corsa/apps/lua/SimHubUDPConnector/manifest.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[ABOUT]
22
NAME = SimHubUDPConnector
33
AUTHOR = DaZD
4-
VERSION = 1.0.16
4+
VERSION = 1.0.17
55
DESCRIPTION = Send properties (key/value) to SimHub via UDP (default port 20777)
66
URL = https://linktr.ee/dazdsim
77

0 commit comments

Comments
 (0)