OpenFunscripter / OFS

A tool to create funscripts
GNU General Public License v3.0
90 stars 39 forks source link

Playhead or action issue with action added through Lua #8

Closed bornforthis2020 closed 3 years ago

bornforthis2020 commented 3 years ago

I've started working on an extension but I'm running in to a weird issue, I don't know if it's something I'm doing (or not doing) I am new to Lua. I noticed when clicking on/moving to actions (added by the function below) that the interval in the stats window read 0.00ms and showed the speed/duration/direction info of the next action. This wouldn't really be much of an issue until you copy/paste onto this point as you then end up with two points at the same time/position which seemed to cause an issue playing the script.

0ms

Here is a simplified version of one of my functions, it adds 101 strokes at an increasing rate of speed.

function test()
    local script = ofs.Script(ofs.ActiveIdx())
    local at = 0
    local speedStep = 4
        for s = 1, 101 do
            ofs.AddAction(script, at, 0, false)
            at = at + (100/(100+(speedStep*(s-1)))*1000)
            ofs.AddAction(script, at, 100, false)
            at = at + (100/(100+(speedStep*(s-1)))*1000)
        end
        --Final Downward Stroke
        ofs.AddAction(script, at, 0, false)
        ofs.Commit(script)
end

The place of the error seems to vary depending on the framerate of the video possibly?

OpenFunscripter commented 3 years ago

This doesn't have anything to do with Lua but thanks to the snippet I was able to reproduce this. I added some fixes.

OpenFunscripter commented 3 years ago

If you want you can download a fixed version from here to try for yourself. https://github.com/OpenFunscripter/OFS/actions/runs/1401885397

There should be a downloadable zip artifact.

bornforthis2020 commented 3 years ago

Thanks, that seems to work