Skip to content

Commit fc9c8f9

Browse files
author
arch
committed
make filter optional
1 parent 6b21764 commit fc9c8f9

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

contrib/Installer/assets/main.lua

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ multiaxis = false
1414
tmpFileName = "funscript_actions.json"
1515
tmpFileExists = false
1616
enableLogs = false
17+
filterSimilarTimestamps = false
1718
scriptNames = {}
1819
scriptNamesCount = 0
1920
scriptAssignment = {x={idx=1}, y={idx=1}, roll={idx=1}}
@@ -124,6 +125,7 @@ function import_funscript_generator_json_result()
124125
json_body = json.decode(content)
125126
actions = json_body["actions"]
126127

128+
local filtered = 0
127129
if multiaxis then
128130
local i = 1
129131
while i <= ofs.ScriptCount() do
@@ -134,9 +136,8 @@ function import_funscript_generator_json_result()
134136
script = ofs.Script(i)
135137
for _, action in pairs(actions[k]) do
136138
local closest_action, _ = script:closestAction(action["at"])
137-
local filtered = false
138-
if closest_action and math.abs(closest_action.at - (action["at"]/1000.0)) < 0.01 then
139-
filtered = true
139+
if filterSimilarTimestamps and closest_action and math.abs(closest_action.at - (action["at"]/1000.0)) < 0.01 then
140+
filtered = filtered + 1
140141
else
141142
script.actions:add(Action.new(action["at"]/1000.0, action["pos"], true))
142143
end
@@ -154,9 +155,8 @@ function import_funscript_generator_json_result()
154155
print('add ', metric, ' to ', ofs.ScriptName(scriptIdx))
155156
for _, action in pairs(actions_metric) do
156157
local closest_action, _ = script:closestAction(action["at"]/1000.0)
157-
local filtered = false
158-
if closest_action and math.abs(closest_action.at - (action["at"]/1000.0)) < 0.01 then
159-
filtered = true
158+
if filterSimilarTimestamps and closest_action and math.abs(closest_action.at - (action["at"]/1000.0)) < 0.01 then
159+
filtered = filtered + 1
160160
else
161161
script.actions:add(Action.new(action["at"]/1000.0, action["pos"], true))
162162
end
@@ -166,6 +166,10 @@ function import_funscript_generator_json_result()
166166
script:commit()
167167
end
168168

169+
if filterSimilarTimestamps then
170+
print('filtered timestamps', filtered)
171+
end
172+
169173
end
170174

171175

0 commit comments

Comments
 (0)