-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.lua
126 lines (108 loc) · 3.78 KB
/
script.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
--script.lua
-----------------DOFILES-----------------
dofile(path .. "/debugMagic.lua")
dofile("scripts/forts.lua")
--dofile("scripts/core.lua") -- Already Loaded
--dofile("scripts/core_utility.lua") -- Already Loaded
dofile(path .. "/BetterLog.lua")
dofile(path .. "/fileList.lua")
FileList.LoadFiles()
---------------API EVENTS----------------
---@type GraphMetaTable
-- TheGraph = nil
function Load(gameStart)
LoadMod()
end
function OnRestart()
LoadMod()
end
function OnSeek()
LoadMod()
end
function OnSeekStart()
LoadMod()
end
function Update(frame)
-- TheGraph:Log(gcinfo(), GetRealTime())
ModLoop(frame)
end
function OnInstantReplaySystem()
for i = 0, 255, 40 do
Notice(RgbaToHex(i, 255, 255 - i, 255, false) .. "Warning: Instant replays are currently broken in Landcruisers, please view from the replay menu instead.")
end
end
function OnUpdate()
end
function OnDraw()
ModDraw()
end
function OnDeviceCreated(teamId, deviceId, saveName, nodeA, nodeB, t, upgradedId)
DeviceManager.OnDeviceCreated(teamId, deviceId, saveName, nodeA, nodeB, t, upgradedId)
end
function OnDeviceMoved(teamId, deviceId, temporaryDeviceId, saveName)
DeviceManager.OnDeviceMoved(teamId, deviceId, temporaryDeviceId, saveName)
end
function OnDeviceDeleted(teamId, deviceId, saveName, nodeA, nodeB, t)
DeviceManager.OnDeviceDeleted(teamId, deviceId, saveName, nodeA, nodeB, t)
end
function OnDeviceDestroyed(teamId, deviceId, saveName, nodeA, nodeB, t)
DeviceManager.OnDeviceDestroyed(teamId, deviceId, saveName, nodeA, nodeB, t)
end
function OnDeviceTeamUpdated(oldTeamId, newTeamId, deviceId, saveName)
DeviceManager.OnDeviceTeamUpdated(oldTeamId, newTeamId, deviceId, saveName)
end
function OnNodeBroken(nodeId, nodeIdNew)
DeviceManager.OnNodeBroken(nodeId, nodeIdNew)
end
-----------------MOD-------------------
function LoadMod()
WheelDefinitionHelpers.ConstructWheelDefinitions()
DeviceManager.Load()
TrackManager.Load()
DrawableWheel.Load()
TerrainManager.Load()
ForceManager.Load()
-- TheGraph = Graph.New(850, 200, 200, 100, 20, "kB / 100,000 kB", "Memory Usage")
UpdateLogging.Load()
MouseWheel.Load()
end
PreviousUpdateTime = 0
UpdateDelta = 0
function ModLoop(frame)
local currentTime = GetRealTime()
local difference = currentTime - PreviousUpdateTime
UpdateDelta = math.floor(difference * 100 + 0.5) / 100
PreviousUpdateTime = currentTime
UpdateFunction("UpdateLogging", "Update", frame)
UpdateFunction("TerrainManager", "Update", frame)
UpdateFunction("DeviceManager", "Update", frame)
UpdateFunction("MouseWheel", "Update", frame)
UpdateFunction("WheelManager", "Update", frame)
UpdateFunction("TrackManager", "Update", frame)
UpdateFunction("ForceManager", "Update", frame)
if ModDebug.update then
local endUpdateTime = GetRealTime()
local delta = (endUpdateTime - currentTime) * 1000
if (UpdateLogging.updateGraph) then
UpdateLogging.updateGraph:Log(delta/(UpdateDelta * 1000) * 100, endUpdateTime)
end
UpdateLogging.Log("Mod loop took " .. string.format("%.2f", delta) .. "ms, " .. string.format("%.1f", delta/(UpdateDelta * 1000) * 100) .. "%")
end
end
PreviousDrawTime = 0
function ModDraw()
local newDrawTime = GetRealTime()
if IsPaused() then PreviousDrawTime = newDrawTime; return end
TrackManager.Draw(PreviousUpdateTime, newDrawTime, PreviousDrawTime)
PreviousDrawTime = newDrawTime
Graph.Update(newDrawTime)
end
function RgbaToHex(r, g, b, a, UTF16)
local hex = string.format("%02X%02X%02X%02X", r, g, b, a)
if UTF16 == true then
return L"[HL="..towstring(hex)..L"]"
else
return "[HL="..hex.."]"
end
end
dofile(path .. "/debugMagic.lua")