WoW:User defined functions: Difference between revisions

From AddOn Studio
Jump to navigation Jump to search
m (catfix)
(Typo fixing using AWB)
Line 11: Line 11:
: [[setArgs]](myTable, "name", ...) - remember list of arguments to use for a callback
: [[setArgs]](myTable, "name", ...) - remember list of arguments to use for a callback
: [[getArgs]](myTable, "name", ...) - retreive stored list of arguments, plus optional extras
: [[getArgs]](myTable, "name", ...) - retreive stored list of arguments, plus optional extras
: [[GetReturnValues|GetReturnValues]](order, functionCall) - Get the return values from ''functionCall'' in any ''order'' you want.
: [[GetReturnValues]](order, functionCall) - Get the return values from ''functionCall'' in any ''order'' you want.


== Color Functions ==
== Color Functions ==
Line 24: Line 24:


== Event Functions ==
== Event Functions ==
:[[User:Egingell/PLAYER_MONEY|PLAYER_MONEY]] - Add a message to the chat frame when you gain or spend money.
:[[User:Egingell/PLAYER MONEY|PLAYER_MONEY]] - Add a message to the chat frame when you gain or spend money.


== Frame Functions ==
== Frame Functions ==
Line 51: Line 51:
== Slash Function ==  
== Slash Function ==  
: [[RunSlashCmd]] - Passes a slash command to the chatframe
: [[RunSlashCmd]] - Passes a slash command to the chatframe
: [[SlashCmdList_AddSlashCommand|SlashCmdList_AddSlashCommand]](name, func, ...)
: [[SlashCmdList AddSlashCommand|SlashCmdList_AddSlashCommand]](name, func, ...)


== String Functions ==
== String Functions ==
Line 61: Line 61:
:[[strfindt]](tabCaptures, ...)   - Wrapper for [[API strfind|strfind]]() that returns captures in a table - can be used in if() clauses!
:[[strfindt]](tabCaptures, ...)   - Wrapper for [[API strfind|strfind]]() that returns captures in a table - can be used in if() clauses!
:[[StringHash]]("string")   - Create a fair-quality 32-bit hash of a string
:[[StringHash]]("string")   - Create a fair-quality 32-bit hash of a string
:[[substr]]("string", start [, length])   - Imp [[API_strsub|strsub]]. Returns a string starting from ''start'' to ''length'' characters from ''start'' (identical to the [http://php.net/substr PHP function] of the same name).
:[[substr]]("string", start [, length])   - Imp [[API strsub|strsub]]. Returns a string starting from ''start'' to ''length'' characters from ''start'' (identical to the [http://php.net/substr PHP function] of the same name).


== Table Functions ==
== Table Functions ==
Line 78: Line 78:


[[Category:Interface customization]]
[[Category:Interface customization]]
[[Category:User defined functions| {{PAGENAME}}]]
[[Category:User defined functions| User defined functions]]

Revision as of 21:50, 7 August 2008

WoW API

These are cut-and-paste functions that you can use in your addons, submitted by WoWWiki contributors.

API

The following functions aim at extending the information WoW API provides; some are provided by specialized addons rather than being copy/pastable.

GetSellValue(item) - Returns an item's merchant sell price.
GetMinimapShape() - Returns a string describing the shape of the minimap (square? round? and more)

Arguments & Returns

setArgs(myTable, "name", ...) - remember list of arguments to use for a callback
getArgs(myTable, "name", ...) - retreive stored list of arguments, plus optional extras
GetReturnValues(order, functionCall) - Get the return values from functionCall in any order you want.

Color Functions

ColorGradient(perc, R1, G1, B1, R2, G2, B2[, ...]) - Converts a percent value into a gradient from 2 or more RGB values
HexToRGB("string") - Converts a hex color string to RGB values (0-255)
HexToRGBPerc("string") - Converts a hex color string to RGB values (0.0-1.0)
RGBToHex(red, green, blue) - Converts a RGB value (0-255) into a hex string
RGBPercToHex(red, green, blue) - Converts a RGB value (0.0-1.0) into a hex string

Cursor Functions

GetCursorScaledPosition() - Return the exact position the cursor is at based on scale.

Event Functions

PLAYER_MONEY - Add a message to the chat frame when you gain or spend money.

Frame Functions

GetQuadrant(frame) - Find which quadrant of the screen a frame lies in.
GetUIParentAnchor(frame) - Returns SetPoint args for the frame, anchor is relative to the nearest corner of the screen.
Frame:RegisterEvents(...) - Register n number of events at once.
Frame:UnregisterEvents(...) - Unregister n number of events at once.
Frame:SetManyAttributes(...) - Simple function to embed in a frame to set many atributes at once.
UnregisterEventFromAllFrames(event) - Tell all the frames listening for event to stop listening for it.

Item Functions

EquipItemByLink(link) - Equips the first matching item found in the player's bags.

Localization Tables

LocalizedClassNames - Table of localized classes

Map Functions

GetPlayerBearing() - Returns the player's current facing bearing based on minimap arrow

Menu Functions

Context Menu Maker - Sudo-Class. Add/Remove menu items and show the menu when you're ready.

Metatables

Memorizing table - A special table that calculates values as needed and saves them into itself

Slash Function

RunSlashCmd - Passes a slash command to the chatframe
SlashCmdList_AddSlashCommand(name, func, ...)

String Functions

ChunkSplit(string [, length [, endChars]])   - Split a string into groups of "length" each ending with "endChars" (identical to the PHP function of the same name).
CountChars(haystack, needle)   - Return how many times needle is contained in haystack.
GetWords("string")   - Split words on space boundary, return table
printMSG("string")   - Displays a custom message to the default chat frame, for the user to see (time, code and size saver).
strfindt(tabCaptures, ...)   - Wrapper for strfind() that returns captures in a table - can be used in if() clauses!
StringHash("string")   - Create a fair-quality 32-bit hash of a string
substr("string", start [, length])   - Imp strsub. Returns a string starting from start to length characters from start (identical to the PHP function of the same name).

Table Functions

EraseTable(t) - Erase all values from a table
tinsertbeforeval(tab, valBefore, val)   - Insert one value before another (without knowing its index)
tremovebyval(tab, val)   - Remove a value (without knowing its index)
tcount(tab)   - Count table members (works on non-integer-indexed tables)
tcopy(tabTo, tabFrom)   - Recursively copy contents of one table to another

Time Functions

GameTime:Get()   - Get server time including seconds and milliseconds

See also