From WoWWiki

This user is a notable member of
the
500 club!
/Sig
My Realms
My Characters
-- Returns a list of values in whatever order you specify in order and only those you specify in order.
-- Mostly useful for functions that return multiple values.
-- This function is horribly inefficient, I just wanted to see if it could be done.
ret1, ret2, ... retN = GetReturnValues(order, functionCall) -- [talk]
-- Return how many times needle is contained in haystack.
ret = CountChars(haystack, needle) -- [talk]
-- Imp strsub. Returns a string starting from start to length characters from start (identical to the PHP function of the same name).
ret = substr(string, start [, length]) -- [talk]
-- Split a string into groups of "length" each ending with "endChars" (identical to the PHP function of the same name).
ret = ChunkSplit(string [, length [, endChars]]) -- [talk]
-- Return the exact position the cursor is at based on scale.
x, y = GetCursorScaledPosition() -- [talk]
-- Unregister an event from all applicable frames.
UnregisterEventFromAllFrames(string) -- [talk]
-- Tell the API to stop listen for events (...)
Frame:UnregisterEvents(frame, string, ...) -- [talk]
-- Tell the API to listen for events (...)
Frame:RegisterEvents(frame, string, ...) -- [talk]
-- Register a slash command (add all commands at the end).
SlashCmdList_AddSlashCommand(name, func, ...) -- [talk]
-- Add a message to the chat frame when you gain or lose money.
-- PLAYER_MONEY Event -- [talk]
-- Make a simple context menu.
-- Context Menu Maker -- [talk]
-- round input to n places
number = round(input, n) -- [talk]
What I think functions look like (or should look like) on the inside
function strtrim(str, chars)
if not chars then
chars = " \t"
end
return string.match(str, "["..chars.."]*(.*)["..chars.."]*")
end
-- Helper function
local function AllBagsOpen(bags)
for _,v in pairs(bags) do
if not v:IsShown() then
return false
end
end
return true
end
local available_bags = {}
local frame
function OpenAllBags(arg)
available_bags = wipe(available_bags)
for i=1, NUM_CONTAINER_FRAMES + NUM_BANKBAGSLOTS, 1 do
frame = getglobal("ContainerFrame"..i)
if frame then
available_bags[i] = frame
end
end
if arg == true or arg == 1 then
for _,v in pairs(available_bags) do
v:Show()
v:SetChecked(1)
end
elseif not arg then
if AllBagsOpen(available_bags) then
for _,v in pairs(available_bags) do
v:Hide()
v:SetChecked(0)
end
else
for _,v in pairs(available_bags) do
v:Show()
v:SetChecked(1)
end
end
else
_ERRORMESSAGE('Usage: OpenAllBags([boolean])')
end
end
function getglobal(name)
return _G[name]
end
function EnableAllAddOns()
for i = 1, GetNumAddOns() do
EnableAddOn(i)
end
end
function DisableAllAddOns()
for i = 1, GetNumAddOns() do
DisableAddOn(i)
end
end
function mod(input, mod)
local neg = 1
if input < 0 then
neg = -1
end
input = abs(input)
mod = abs(mod)
return neg * ((input / mod) - floor(input / mod)) * mod
end
function SetBindingSpell(key, command)
if command then
command = "SPELL " .. command
end
return SetBinding(key, command)
end
function SetBindingItem(key, command)
if command then
command = "ITEM " .. command
end
return SetBinding(key, command)
end
function SetBindingMacro(key, command)
if command then
command = "MACRO " .. command
end
return SetBinding(key, command)
end
function SetBindingClick(key, command, button)
if command then
command = "CLICK " .. command
end
if button then
command = command .. ":" .. button
end
return SetBinding(key, command)
end
function UnitBuff(unit, buff, filter)
return UnitAura(unit, buff, "HELPFUL" .. (filter == 1 and "|PLAYER" or ""))
end
function UnitDebuff(unit, buff, filter)
return UnitAura(unit, buff, "HARMFUL" .. (filter == 1 and "|CANCELABLE" or ""))
end
function print(...)
local n
for i = 1, select("#", ...) do
n = select(i, ...)
DEFAULT_CHAT_FRAME:AddMessage(tostring(n))
end
end
External Links