Module ofs

Core functions

Synopsis

Functions
print()

Print to the extension log

clamp()

Clamp a value

ofs.Version()

Get the API version

ofs.ExtensionDir()

Get the extension directory path

ofs.ScriptCount()

Get the currently loaded script count

ofs.ScriptName()

Get the script name

print(...)

Print to the extension log.

Takes a variable amount of arguments strings and numbers.

Example
print("Number", 42) --  "Number 42"
clamp(val, min, max)

Clamp a value

Parameters
val (number)
min (number)
max (number)
Return Values
(number)

Result

ofs.Version()

Get the API version

Return Values
(number)

Version

ofs.ExtensionDir()

Get the extension directory path

Return Values
(string)

Path

ofs.ScriptCount()

Get the currently loaded script count

Return Values
(number)

Count

ofs.ScriptName(scriptIdx)

Get the script name

Parameters
scriptIdx (number)
Return Values
(String)

Name

Funscript

Synopsis

Functions
ofs.ActiveIdx()

Gets the index of the currently active script

ofs.Script()

Get a currently loaded script

Example
local script = ofs.Script(ofs.ActiveIdx())
ofs.Clipboard()

Get a read-only version of the clipboard

ofs.Undo()

Undo the last modification

Note

This function can only undo modifications done by a Lua extension

ofs.ActiveIdx()

Gets the index of the currently active script

Return Values
(number)

scriptIdx

ofs.Script(scriptIdx)

Get a currently loaded script

Example
local script = ofs.Script(ofs.ActiveIdx())
Return Values
(Funscript)

funscript

ofs.Clipboard()

Get a read-only version of the clipboard

Return Values
(Funscript)

clipboard

ofs.Undo()

Undo the last modification

Note

This function can only undo modifications done by a Lua extension.

Return Values
(bool)

hasUndoneSomething

GUI

Important

All of these functions must be called from within the gui() function.

Synopsis

Functions
ofs.Text()

Display text

ofs.Button()

Create a button

Example
if ofs.Button("Click me") then
  print("I was clicked!")
end
ofs.Input()

Create an input field

Example
-- global variables
text = ""
number = 5
function gui()
  text, textChanged = ofs.Input("Text", text)
  number, valueChanged = ofs.Input("Number", number, 2)
end
ofs.InputInt()

Create an input field

ofs.Drag()

Create a numeric drag input

ofs.DragInt()

Create a numeric integer drag input

ofs.Slider()

Create a numeric slider

ofs.SliderInt()

Create a numeric integer slider

ofs.Checkbox()

Create a checkbox

ofs.Combo()

Create a combobox

ofs.CollapsingHeader()

Create a collapsable header

Example
function gui()
  if ofs.CollapsingHeader("abc") then
     ofs.Text("This text is only visible when the header is opened")
  end
end
ofs.SameLine()

Put next control on the same line as the previous

Example
ofs.Button("Button 1")
ofs.SameLine()
ofs.Button("Button 2")
ofs.Separator()

Insert a separator

ofs.NewLine()

Insert a new line between controls

Example
ofs.Button("Button 1")
ofs.NewLine()
ofs.Button("Button 2")
ofs.Tooltip()

Create a tooltip

Example
ofs.Button("...")
ofs.Tooltip("The button does X") -- displayed when hovering the button
ofs.BeginDisabled()

Begin disabled area

Example
ofs.BeginDisabled(true)
ofs.Button("...") -- button is forever disabled
ofs.EndDisabled()
ofs.EndDisabled()

End disabled area

ofs.Text(txt)

Display text

Parameters
txt (string)
Return Values
(nil)
ofs.Button(txt)

Create a button

Example
if ofs.Button("Click me") then
  print("I was clicked!")
end
Parameters
txt (string)
Return Values
(bool)

clicked

ofs.Input(txt, value, stepSize)

Create an input field

Example
-- global variables
text = ""
number = 5
function gui()
  text, textChanged = ofs.Input("Text", text)
  number, valueChanged = ofs.Input("Number", number, 2)
end
Parameters
txt (string)
value (string or number)
stepSize (number or nil)

only applies to numeric inputs,

Return Values
1. (string or number)

value

2. (bool)

valueChanged

ofs.InputInt(txt, value, stepSize)

Create an input field

Parameters
txt (string)
value (string or number)
stepSize (number or nil)

only applies to numeric inputs,

Return Values
1. (number)

value

2. (bool)

valueChanged

ofs.Drag(txt, value, stepSize)

Create a numeric drag input

Parameters
txt (string)
value (number)
stepSize (number or nil)
Return Values
1. (number)

value

2. (bool)

valueChanged

ofs.DragInt(txt, value, stepSize)

Create a numeric integer drag input

Parameters
txt (string)
value (number)
stepSize (number or nil)
Return Values
1. (number)

value

2. (bool)

valueChanged

ofs.Slider(txt, value, min, max)

Create a numeric slider

Parameters
txt (string)
value (number)
min (number)
max (number)
Return Values
1. (number)

value

2. (bool)

valueChanged

ofs.SliderInt(txt, value, min, max)

Create a numeric integer slider

Parameters
txt (string)
value (number)
min (number)
max (number)
Return Values
1. (number)

value

2. (bool)

valueChanged

ofs.Checkbox(txt, checked)

Create a checkbox

Parameters
txt (string)
checked (bool)
Return Values
1. (bool)

checked

2. (bool)

checkChanged

ofs.Combo(txt, currentIdx, items)

Create a combobox

Parameters
txt (string)
currentIdx (number)
items (string[])
Return Values
1. (number)

currentIdx

2. (bool)

selectionChanged

ofs.CollapsingHeader(txt)

Create a collapsable header

Example
function gui()
  if ofs.CollapsingHeader("abc") then
     ofs.Text("This text is only visible when the header is opened")
  end
end
Parameters
txt (string)
Return Values
(bool)

headerOpened

ofs.SameLine()

Put next control on the same line as the previous

Example
ofs.Button("Button 1")
ofs.SameLine()
ofs.Button("Button 2")
Return Values
(nil)
ofs.Separator()

Insert a separator

Return Values
(nil)
ofs.NewLine()

Insert a new line between controls

Example
ofs.Button("Button 1")
ofs.NewLine()
ofs.Button("Button 2")
Return Values
(nil)
ofs.Tooltip(txt)

Create a tooltip

Example
ofs.Button("...")
ofs.Tooltip("The button does X") -- displayed when hovering the button
Parameters
txt (string)
Return Values
(nil)
ofs.BeginDisabled(disabled)

Begin disabled area

Example
ofs.BeginDisabled(true)
ofs.Button("...") -- button is forever disabled
ofs.EndDisabled()
Parameters
disabled (bool)
Return Values
(nil)
ofs.EndDisabled(disabled)

End disabled area

Return Values
(nil)