-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.lua
123 lines (105 loc) · 5.16 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
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
local STS = {
description = "Scopes that Scope",
configs = dofile("app/configs.lua"),
help = dofile('app/helpers.lua')
}
function STS.init()
registerForEvent("onInit", function()
local scopes = STS.configs.load()
STS.settings = GetMod("nativeSettings")
STS.settings.addTab("/STS", "Scopes that Scope")
for scopeKind, scopeIndexes in pairs(scopes) do
for scopeIndex, stats in pairs(scopeIndexes) do
STS.settings.addSubcategory("/STS/" .. stats['name'],
STS.help.capitalize(scopeKind) .. ": " .. STS.help.capitalize(stats['name']))
--path, label, desc, min, max, step, currentValue, defaultValue, callback
STS.settings.addRangeFloat(
"/STS/" .. stats['name'], --path
"Zoom Level", --label
"Zoom Level", --description
0, --min
12, --max
0.25, --step
"%.2f", --format
stats['ZoomLevel']['custom'] + 0.0, --currentValue
stats['ZoomLevel']['default'] + 0.0, --defaultValue
function(value) --callback
SetScopeZoom(
scopeKind,
scopeIndex, stats['ZoomLevel']['custom'] + 0.0,
stats['ZoomLevel']['inlineIndex'],
stats['ZoomLevel']['combinedInlineIndex']
)
scopes[scopeKind][scopeIndex]['ZoomLevel']['custom'] = value
STS.configs.save(scopes)
end
)
if (stats['RangeBonus'] ~= nil) then
STS.settings.addRangeFloat(
"/STS/" .. stats['name'], --path
"Range", --label
"Range", --description
0, --min
200, --max
1, --step
"%.0f", --format
stats['RangeBonus']['custom'] + 0.0, --currentValue
stats['RangeBonus']['default'] + 0.0, --defaultValue
function(value) --callback
SetScopeRange(
scopeKind,
scopeIndex,
stats['RangeBonus']['custom'] + 0.0,
stats['RangeBonus']['inlineIndex'],
stats['RangeBonus']['combinedInlineIndex']
)
scopes[scopeKind][scopeIndex]['RangeBonus']['custom'] = value
STS.configs.save(scopes)
end
)
end
SetScopeZoom(
scopeKind,
scopeIndex, stats['ZoomLevel']['custom'] + 0.0,
stats['ZoomLevel']['inlineIndex'],
stats['ZoomLevel']['combinedInlineIndex']
)
if (stats['RangeBonus'] ~= nil) then
SetScopeRange(
scopeKind,
scopeIndex,
stats['RangeBonus']['custom'] + 0.0,
stats['RangeBonus']['inlineIndex'],
stats['RangeBonus']['combinedInlineIndex']
)
end
end
end
end
)
return {
STS = STS
}
end
function SetScopeZoom(scopeKind, scopeIndex, zoomLevel, inlineIndex, combinedInlineIndex)
local zoomLevelPath = "Items.w_att_scope_" .. scopeKind .. "_" .. scopeIndex .. "_inline" .. inlineIndex
--zoomLevel
TweakDB:SetFlat(zoomLevelPath .. ".value", zoomLevel)
--zoomQualityMultiplier
if (combinedInlineIndex ~= nil) then
local zoomQualityMultiplierPath = "Items.w_att_scope_" ..
scopeKind .. "_" .. scopeIndex .. "_inline" .. combinedInlineIndex
TweakDB:SetFlat(zoomQualityMultiplierPath .. ".modifierType", "Invalid")
end
end
function SetScopeRange(scopeKind, scopeIndex, rangeBonus, inlineIndex, combinedInlineIndex)
local rangeBonusPath = "Items.w_att_scope_" .. scopeKind .. "_" .. scopeIndex .. "_inline" .. inlineIndex
--rangeBonus
TweakDB:SetFlat(rangeBonusPath .. ".value", rangeBonus)
if (combinedInlineIndex ~= nil) then
local rangeBonusPath = "Items.w_att_scope_" .. scopeKind .. "_" .. scopeIndex .. "_inline" .. combinedInlineIndex
TweakDB:SetFlat(rangeBonusPath .. ".modifierType", "Invalid")
end
--print("STS: " .. scopeKind .. " " .. scopeIndex .. " Range set to " .. value)
end
return STS.init()