View Single Post
04/21/14, 11:07 AM   #1
BadVolt
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 74
Some new useful ingame functions

Found some new ingame functions. Feel free to document and use them

Misc
  1. zo_binaryinsert (item, searchData, dataList, comparator)
  2. zo_binaryremove (searchData, dataList, comparator)
  3. zo_binarysearch (searchData, dataList, comparator)
  4. zo_callHandler (object, handler, ...)
  5. zo_clamp(value, minimum, maximum)
  6. zo_deltaNormalizedLerp (from, to, amount)
  7. zo_iconFormat(path, width, height)
  8. zo_iconTextFormat(path, width, height, text)
  9. zo_round(value)
  10. zo_roundToNearest(value, nearest)
  11. zo_roundToZero(value)
  12. zo_strtrim(str)

Tree node:
  1. ZO_TreeNode:New(myTree, controlData, myParent, childIndent)
    return node
  2. ZO_TreeNode:SetExpandedCallback(callback)
  3. ZO_TreeNode:ToggleExpanded(expanded)
  4. ZO_TreeNode:IsExpanded()
  5. ZO_TreeNode:IsShowing()
  6. ZO_TreeNode:HasChildren()
  7. ZO_TreeNode:GetNestingLevel()
    return nestingLevel
  8. ZO_TreeNode:GetControl()
    return self.m_Control
  9. ZO_TreeNode:GetOwningTree()
    return self.m_OwningTree
  10. ZO_TreeNode:GetNextSibling()
    return self.m_Sibling
  11. ZO_TreeNode:GetParent()
    return self.m_Parent
  12. ZO_TreeNode:GetChildIndent()
    return self.m_ChildIndent
  13. ZO_TreeNode:SetOffsetY(offsetY)


Tree control:
  1. ZO_TreeControl:New(initialAnchor, indentXOffset, verticalSpacing)
    return tree
  2. ZO_TreeControl:AddChild(atNode, insertedControl, childIndent)
    return ?
  3. ZO_TreeControl:AddSibling(atNode, insertedControl, childIndent)
    return ?
  4. ZO_TreeControl:AddSiblingAfterNode(atNode, insertedControl, childIndent)
    return ?
  5. ZO_TreeControl:RemoveNode(node)
  6. ZO_TreeControl:Clear()
  7. ZO_TreeControl:Update(updateFromNode, indent, anchor, firstControl)
    return anchor, indent

Table functions:
  1. NonContiguousCount(tableObject)
    return count
  2. ZO_TableOrderingFunction(entry1, entry2, sortKey, sortKeys, sortOrder)
    return: bool

    Arguments:
    entry1 (table) An entry in the table being sorted
    entry2 (table) Another entry in the table being sorted
    sortKey (non nil) A key in the entry arguments (tableX[sortKey]) to be used for sorting.
    sortKeys (table) A table whose keys are all keys in entryX and whose values are all tables
    (optionally containing tiebreaker and isNumeric)
    sortOrder (number) Must be ZO_SORT_ORDER_UP or ZO_SORT_ORDER_DOWN

    Return:
    When sortOrder is ZO_SORT_ORDER_UP: entry1[sortKey] < entry2[sortKey]
    When sortOrder is ZO_SORT_ORDER_DOWN: entry1[sortKey] > entry2[sortKey]

  3. ZO_ClearNumericallyIndexedTable(t)
  4. ZO_ClearTable(t)
  5. ZO_ShallowTableCopy(source, dest)
    return table
  6. ZO_DeepTableCopy(source, dest)
    return table

Hooking API
Install a handler that will be called before the original function and whose return value will decide if the original even needs to be called.
If the hook returns true it means that the hook handled the call entirely, and the original doesn't need calling.
ZO_PreHook can be called with or without an objectTable; if the argument is a string (the function name), it just uses _G


  1. ZO_PreHook(objectTable, existingFunctionName, hookFunction)
    return function (?)
  2. ZO_PreHookHandler(control, handlerName, hookFunction)
    return function (?)

Callback Manager
  1. ZO_CallbackObject:New()
  2. ZO_CallbackObject:RegisterCallback(eventName, callback, arg)
    Registers a callback to be executed when eventName is triggered.
    You may optionally specify an argument to be passed to the callback.


  3. ZO_CallbackObject:UnregisterCallback(eventName, callback)
  4. ZO_CallbackObject:FireCallbacks(eventName, ...)
    return result(?)
    Executes all callbacks registered on this object with this event name
    Accepts the event name, and a list of arguments to be passed to the callbacks
    The return value is from the callbacks, the most recently registered non-nil non-false callback return value is returned


  5. ZO_CallbackObject:Clean(eventName)

Last edited by BadVolt : 04/21/14 at 01:14 PM.
  Reply With Quote