File ../../LibScriptablePlugins-1.0/LibScriptablePluginUtils-1.0/LibScriptablePluginUtils-1.0.lua

Functions

PluginUtils.ConvertMethodToFunction (namespace, func_name) Leave a function as-is or if a string is passed in, convert it to a namespace-method function call.
PluginUtils.GetCoords (n, pitch) Retrieve the column and row coordinates for the provided index and pitch
PluginUtils.Intersect (frame1, frame2, frame1xPad1, frame1yPad1, frame1xPad2, frame1yPad2, frame2xPad1, frame2yPad1, frame2xPad2, frame2yPad2) Intersect - Find out if two frames intersect, adjusted by paddings.
PluginUtils.IsPowerOf2 (n) Determine if the number provided is a power of 2
PluginUtils.Split (str, delim) Split a string using the delimiter provided
PluginUtils:New (environment) Populate an environment with this plugin's fields


Functions

PluginUtils.ConvertMethodToFunction (namespace, func_name)
Leave a function as-is or if a string is passed in, convert it to a namespace-method function call.

Parameters

  • namespace: a table with the method func_name on it
  • func_name: a function (which would then just return) or a string, which is the name of the method.

Usage

  • PluginUtils.ConvertMethodToFunction({}, function(value) return value end)("blah") == "blah"
  • PluginUtils.ConvertMethodToFunction({ method = function(self, value) return value end }, "method")("blah") == "blah"

Return value:

a function
PluginUtils.GetCoords (n, pitch)
Retrieve the column and row coordinates for the provided index and pitch

Parameters

  • n: An index within a buffer
  • pitch: Your surface's column width

Usage:

GetCoords(n, pitch)

Return value:

The column and row representing the provided data
PluginUtils.Intersect (frame1, frame2, frame1xPad1, frame1yPad1, frame1xPad2, frame1yPad2, frame2xPad1, frame2yPad1, frame2xPad2, frame2yPad2)
Intersect - Find out if two frames intersect, adjusted by paddings. usage Intersect(frame1, frame2, frame1xPad1, frame1yPad1, frame1xPad2, frame1yPad2, frame2xPad1, frame2yPad1, frame2xPad2, frame2yPad2)

Parameters

  • frame1: The first frame to compare.
  • frame2: The second frame to compare.
  • frame1xPad1: Padding for left side of frame1
  • frame1yPad1: Padding for top side of frame1
  • frame1xPad2: Padding for right side of frame1
  • frame1yPad2: Padding for bottom of frame1
  • frame2xPad1: Padding for left side of frame2
  • frame2yPad1: Padding for top side of frame2
  • frame2xPad2: Padding for right side of frame2
  • frame2yPad2: Padding for bottom of frame2

Return value:

True if the two frames intersect, false otherwise
PluginUtils.IsPowerOf2 (n)
Determine if the number provided is a power of 2

Parameters

  • n: A number value

Usage:

IsPowerOf2(n)

Return value:

A boolean indicating whether the value is a power of 2 or not
PluginUtils.Split (str, delim)
Split a string using the delimiter provided

Parameters

  • str: The string to split
  • delim: The delimiter should be a single character

Usage:

Split(str, delim)

Return value:

A new table populated with the split substrings
PluginUtils:New (environment)
Populate an environment with this plugin's fields

Parameters

  • environment:

Usage:

:New(environment)

Return value:

A new plugin object, aka the environment

Valid XHTML 1.0!