WoW:User defined functions: Difference between revisions

From AddOn Studio
Jump to navigation Jump to search
No edit summary
Line 1: Line 1:
{{breadcrumb1|Interface Customization}}
{{wowapi}}__NOTOC__{{breadcrumb1|Interface Customization}}


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


Please use [[Boilerplate: User Defined Function]] when submitting new functions.
Please use [[Boilerplate: User Defined Function]] when submitting new functions.
== 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
== Frame Functions ==
:[[Frame:SetManyAttributes]](...) - Simple function to embed in a frame to set many atributes at once.
== Item Functions ==
:[[EquipItemByLink]](link) - Equips the first matching item found in the player's bags.
== Localization Tables ==
: [[LocalizedClassNames]] - Table of localized classes


== String Functions ==
== String Functions ==
Line 13: Line 29:


== Table Functions ==
== Table Functions ==
:[[EraseTable]](t) - Erase all values from a table
:[[tinsertbeforeval]](tab, valBefore, val)   - Insert one value before another (without knowing its index)
:[[tinsertbeforeval]](tab, valBefore, val)   - Insert one value before another (without knowing its index)
:[[tremovebyval]](tab, val)   - Remove a value (without knowing its index)
:[[tremovebyval]](tab, val)   - Remove a value (without knowing its index)

Revision as of 22:47, 10 April 2007

WoW APITemplate:Breadcrumb1

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

Please use Boilerplate: User Defined Function when submitting new functions.

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

Frame Functions

Frame:SetManyAttributes(...) - Simple function to embed in a frame to set many atributes at once.

Item Functions

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

Localization Tables

LocalizedClassNames - Table of localized classes

String Functions

GetWords("string")   - Split words on space boundary, return table
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
printMSG("string")   - Displays a custom message to the default chat frame, for the user to see (time, code and size saver).

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