A python script to fix .funscript for Kiiroo Onyx+

Hi there!

I recently purchased a Kiiroo Onyx+, but in almost every funscript I played through the different players, the Onyx+ would shut down anywhere mid-scene and flash its light red, only working again when turned off and on again.

I tried to diagnose the problem, and indeed the Onyx+ seems to have a problem when the interval between two entries in the funscript actions list is more than about 3 seconds. Therefore, I wrote a little Python script which interpolates additional action points into the script (so that the maximum interval is 2000 ms), therefore causing the Onyx+ to run the full session without problems (at least in my tests).

You can find the snippet below; maybe developers of funscript players might want to incorporate a workaround like this directly into the player?


#!/usr/bin/env python3
#To use this script, just run it via the python3 command in your command line and provide input and output files as parameters

import json
import math
import sys

def interpolate(a_this, a_next, interval):
	interpolated = []
	distance = a_next["at"]-a_this["at"]
	if distance > interval:
		velocity = (a_next["pos"]-a_this["pos"])/distance
		steps = int(math.ceil(distance/interval))
		step_width = distance/steps
		for i in range(1, steps):
				"at": int(a_this["at"] + i*step_width),
				"pos": int(a_this["pos"] + velocity*i*step_width)
	return interpolated

def main(f_in, f_out):
	with open(f_in, "r") as f:
		script = json.loads(f.read())
	old_actions = script["actions"]
	new_actions = []
	for a_this, a_next in zip(old_actions, old_actions[1:]):
		new_actions += [a_this] + interpolate(a_this, a_next, 2000)
	script["actions"] = new_actions
	with open(f_out, "w") as f:

if __name__ == '__main__':
	main(sys.argv[1], sys.argv[2])


Could you break down exactly how to do this? Im having the same problem…
:pray: :pray: :pray:


Hi @Dedddunk
it is actually pretty straight forward. I will try my best to break it down for someone who never used python before.

  1. Basically you need to install python (which is a programming language) on your computer. Check this link to get started: Python For Beginners | Python.org
  2. When you open a command prompt (e.g. Terminal), you should be able to type python3 --version, which should give you something like Python 3.9.10 or whichever version you installed.
  3. Create a new text file with the code I provided in the initial post and save it, for example “funscript_fixer.py”.
  4. Type python3 /path/to/folder/funscript_fixer.py /path/to/broken.funscript /path/to/save/fixed.funscript. This instructs python3 to execute the program saved at /path/to/folder/funscript_fixer.py, which reads the funscript saved at /path/to/broken.funscript and creates a new, fixed version of the file at /path/to/save/fixed.funscript.

im def doing something wrong
i keep getting “Syntaxerror: invalid syntax”
please help!
:pray: :pray: :pray:

Okay. Are you on Windows or macOS/Linux?
If you type python3 --version , what is your result?

Im on windows
heres a screenshot of what i got so far
Screenshot 2022-03-08 193029

im also having the same issue and i cant really figure out how to run the script properly through the command terminal

This worked for me. I was having exactly the same problem and this fixes it. Here’s a how to:

I’m on windows 11 and so I went to the start icon and opened a command window (type “cmd” in the Type here to search) and tried to start python3. python3 wasn’t installed so windows helpfully took me to the app store to install it. So far so good. Now when I type python3 it does take me into the python interpreter. Ctrl-Z to get out.

Now cut and paste the python program above into a file. I just called it fix.py. Use notepad or something to create the file and get the contents to look like the file above. I fiddled with the name of the file to get the .txt off the end that windows and notepad like to put on.

Now, for the purposes of illustration, I wanted to fix up the script that goes with Noodedude’s pmv. The file when downloaded, say, is called “NoodleDude Cock Hero.funscript”. Because of the blank in the filename you need to put some quotes around things - I entered the command

python3 fix.py “NoodleDude Cock Hero.funscript” “NoodleDude Cock Hero.funscript2”

Then I needed to get rid of the original file and then take the 2 off the name of the new one so I just had the new file called NoodleDude Cock Hero.funscript back. But any way of naming and renaming that works for you is fine, there’s nothing special about the 2 on the end.

Hope that helps. It’s greatly added to my enjoyment of quite a few scripts, all of which were pretty annoying in the way they upset the Onyx, so thank you to the original author.

Is there a way to batch-convert an entire folder of funscripts? Doing one at a time is a tedious process. If so, please outline the steps for a non-coder.

1 Like

Hey, is there any way of getting this to work with Virt-a-mate?
It uses Intiface, which then connects to a proprietary plugin called VAMSync3 which can then be picked up by Virt-a-mate. What I’m essentially asking, is can this python script be altered so that it is picked up at an intiface level, and not scriptplayer which is a level further? If it worked against intiface then you’ve got a solution here that works fixes the solution regardless of the platform it’s being used on!

This script takes a funscript file altersbthe points and then writes a new funscripts file. Im not sure what you mean by “picked up by” intiface or scriptplayer. Its just creating a new funscript that can be played by whatever player you happen to be using.