-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.lua
51 lines (41 loc) · 1.27 KB
/
init.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
local GameSettings = require('modules/GameSettings')
local GameSession = require('modules/GameSession')
local ToggleHud = {
hud_group_path = '/interface/hud',
crosshair_path = '/interface/hud/crosshairs',
hud_hidden = false,
hud_settings = {}
}
function ToggleHud:hideHud()
local hud_group = Game.GetSettingsSystem():GetGroup(self.hud_group_path)
-- save HUD settings
self.hud_settings = GameSettings.ExportVars(nil, hud_group)
-- hide HUD
GameSettings.SetGroupBool(self.hud_group_path, false)
end
function ToggleHud:restoreHud()
GameSettings.ImportVars(self.hud_settings)
end
function ToggleHud:new()
registerForEvent('onInit', function()
-- restore hud on exit in case it was hidden
GameSession.OnEnd(function()
if self.hud_hidden then
self:restoreHud()
end
end)
end)
registerHotkey('ToggleHUD', 'Toggle HUD', function()
if not self.hud_hidden then
self:hideHud()
else
self:restoreHud()
end
self.hud_hidden = not self.hud_hidden
end)
registerHotkey('ToggleCrosshair', 'Toggle Crosshair', function()
GameSettings.Toggle(self.crosshair_path)
end)
return self
end
return ToggleHud:new()