Skip to content

Commit 55b33ec

Browse files
committed
blender: Ensure exported scripts are valid
Ensure all values in the exported script are valid by capping values and ignoring all input before the start of the movie.
1 parent 6a2a328 commit 55b33ec

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

funscripting.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
bl_info = {
3333
"name": "Funscripting Addon",
3434
"author": "Funjack",
35-
"version": (0, 0, 5),
35+
"version": (0, 0, 6),
3636
"location": "Sequencer",
3737
"description": "Script Launch haptics data and export as Funscript.",
3838
"category": "Sequencer",
@@ -283,7 +283,13 @@ def create_funscript(keyframes, inverted):
283283
script = []
284284
for kf in keyframes:
285285
time = frame_to_ms(int(kf.co[0]))
286+
if time < 0:
287+
continue
286288
value = int(kf.co[1])
289+
if value < 0:
290+
value = 0
291+
elif value > 100:
292+
value = 100
287293
script.append({"at": time, "pos": value})
288294
return {"version": "1.0", "inverted": inverted, "range": 100, "actions": script}
289295

0 commit comments

Comments
 (0)