Kingleon99's - Lua Script Collection [OFS]

:memo: Notes

This is my Personal Lua Script collection, which I’ve been using for a few months now, and I think it’s useful enough to share it online.

You can inform me, If you find any bugs.
(at best a screenshot of the error message or copy and paste the massage)

Don’t forget to assign Hotkeys if you want to get the most out of the script.

Hotkey Instruction

HotKeys

:notebook_with_decorative_cover: History

I am not a Learned Programmer, I just played around with C# for some years and when I saw that you could make your own scripts I was a bit reluctant at first and only used other people’s stuff, but some were too complicated to understand, others didn’t do what I exactly wanted, so I decided to look into Lua and the OFS Extension API and started making my own Scripts, which were individual scripts at the beginning, but it quickly annoyed my how many tabs I had open, so I put them in one Script.

For me they work(most of the time) and are really useful when combined with other people’s scripts.

And I hope they are useful for you too. :grinning:

Changelog

v0.3
First Release
2024-02-21T00:00:00Z

v0.3.1
Improved Limit (was made quite hastily should work better now)
2024-02-21T13:20:00Z

v0.3.2
Improved Equalize
added version text next to Execute Button
2024-02-25T19:00:00Z

v0.4.0
Added count Selected to Switch
Limit now includes first and last Point of the Script
Limit workes now with up and up & down and down movement not just up & down (Doesn’t work with too funky Scripts)
Added Vibrate Function (not as sophisticated as other’s Vibrate Scripts)
2024-03-14T16:00:00Z

v0.4.1
Fixed small mistake which made Switch crash when using First
Changed Vibrates Amount Lower Limit from 3 to 1
Added Function AddMovement
2024-04-01T16:20:00Z

v0.4.2
BPM got a adjustable EndPoint
AddMovement got a LowerLimit (If Speed in the other Direction is lower than LowerSpeed a Point with LowerSpeed is created)
AddMovement Limited Max Amount of Points Used at once to 1400 otherwise OFS crashes (at least for me)
AddMovement Works now with Points that are not at 0 (both Points still need to have the same value doe)
Limit has now the option to scale from a Start to End
2024-04-08T18:15:00Z

v0.4.3
Fixed SmoothWaves not working after using it with 0 Points selected
Crashes based on Creating Points on same position shouldn’t happen anymore
2024-04-28T21:50:00Z

v0.4.4
BeatsPerMinute works now with empty Scripts
Multiply has now too the option to scale from a Start to End
2024-05-19T16:20:00Z

v0.4.5
Find can now find based on Speed not just Position
Added Funtion CleanUp
2024-07-15T19:10:00Z

:information_source: Info

Here I will explain what each function does.

[with exception of BPM all Functions will need selected points]

SmoothWaves

SmoothWaves

My First and most complicated Function, but also the one I am really proud of.

Smooth Waves Info|387x295,

I hope the name at least hints at what it does. It adds Points between existing Points of a Wave Pattern defined by the Edgesize and the Factor, where Edgesize is the Horizontal direction & Factor the Vertical one, You can also decide on which area a Point should be created. The % decides if the Factor is Absolute (always same) or depends on the difference between the two Points.

Before

After

Example1

Example2

Example3

Multiply

Really simple, It multiplies either the Value(pos) or time(at) of the Points

Multiply Info

Scale

Simple too, It Scales from the Higher Point to the lower one.

Scale Info

Before

Scale

After

ScaleAfter

Math.Round

Every Programmer should know what this is. Well it Rounds the Points by the Factor, so if Factor is 5 74 will be 75 , 72 will be 70 and so on, not too complicated.

Math.Round Info

Switch

Will Keep Points selected based on Target.
So if one, every other Point will stay selected

Switch Info

BeatsPerMinute

Will place Points based on the BPM,
if you script a HMV or PMV and you know the BPM of the song, this will be helpful.
Important it will start from the current time in the script, not the beginning of the video

BeatsPerMinute Info

Limit

Will try to limit the speed between Points.

Limit Info

Before

Limit

After

LimitAfter

Find

Will select Points between the Top & Bottom value.

Find Info

Equalize

Like the build in Equalize, with the exception that it groups the Points together that have a similar distance, how similar is decided by the Tolerance.

Equalize Info

Before

After

Vibrate

Adds Points where every second point gets changed, Timeoffset obviously changes the Time, where FactorStart and FactorEnd changes the value

Vibrate Info

Before

After

AddMovement

Adds a configurable Point Between 2 Points

AddMovement Info

Before

After

CleanUp

A Few Ways to Remove Unnecessary Points

CleanUp

SamePos

Before

CleanUp PosBefore

After

CleanUp PosAfter

SameSpeed&Direction

Before

After

:open_file_folder: Download

Unzip in C:\Users\YourUsername\AppData\Roaming\OFS\OFS3_data\extensions

11 Likes

nice, can you explain your smooth waves implementation please?

edit: nvm i see you did. im retarded

edit again: Have you noticed any patterns in relation to what an ideal smoothing distance in terms of horizontal and vertical distances would be. With the goal being that when a device transitions from down to up or vice versa, no jolt or jerk is felt?

after using this for a bit. Well fucking done dude.

That depends on which device you plan to script for the Handy which I have and script for has a maximum speed of 600 units/s even though I try not to go over 500, but you should decide for what device you want to script for and keep its max speed in mind.

Most of the time when I use it, I play around (undo and change values) with it until I’m satisfied with the result.

what is this

Not quite sure what you mean, but this is a post about my Lua script for Openfunscripter,
not important if you don’t make funscripts yourself.

1 Like

This is my first exposure to this and it looks very cool. Wanted to say thanks! Does it work with OFS 3.2.0?

3.2.0 is the version that I have, which is the newest version I think, so yeah should work

Installed it and it seems great so far. I’m definitely going to use a few of these. I look forward to looking into the code a bit as I’ve only ever briefly checked out Lua (for OFS) and quickly moved on.

Yeah I have a handy. I was more thinking of a script that would smooth each change in direction on its own. So my idea was to select all points and use a “smooth all” option.

I have run into many issues attempting this when there are points that deviate from direct vertical movement. For example; points at

200ms:0, 400ms:100, 600ms:0, 800ms:100

Would work just fine. But points at

200ms:0, 400ms:40, 600ms:90, 800ms:0.

This less orderly pattern causes various issues with the placement of the new points.

I have had to go down some complex math roads to try to solve it. I think it will require a lengthy algorithm to handle each possible deviation. If youre interested in a challenge let me know I can show you what i’ve been trying.

Well, I am by no means an expert about programming. That bit that I can do is self-taught, so I wouldn’t put your hopes too high, but you can show me what you did so far. It couldn’t hurt, at least.

i wasnt sure what it was thank you for clarifying

Note, the handy normaly actualy doesnt reach 600ups. If it can its only for 0-100 movement, but as far as i know it wont do that even in those cases

The actual limit is just 400ups. And this is reliable. The only reason to script above it is because if you take this limit, you often will not actualy ask for the limit of the device. If a point was slightly adjusted, a 400ups stroke might become just 350ups. So on that i definitely recommend not taking 400 as limit, 450 or 500 is just better (for me it depends on the section which is better. for long strokes i will even go to 600 just in case a device can play it back properly).

By exceeding the 400 slightly, even if the device doesnt playback the positions properly, it does go for the speed. 500ups is on that a fairly safe value. Its even that safe that it can handle vibrations (600 is often not managable, but depending on script and firmware still possible).

If however carefully scripting even 450 is going to be a fine limit. Above that, if you have a CH video, the vertical alignment might be pushed towards a certain point (ie. if you want it to touch the bottom, it might never do that).