@@ -14,6 +14,7 @@ multiaxis = false
1414tmpFileName = " funscript_actions.json"
1515tmpFileExists = false
1616enableLogs = false
17+ filterSimilarTimestamps = false
1718scriptNames = {}
1819scriptNamesCount = 0
1920scriptAssignment = {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+
169173end
170174
171175
0 commit comments