WoW:User defined functions: Difference between revisions

From AddOn Studio
Jump to navigation Jump to search
No edit summary
 
Line 1: Line 1:
== User Defined Functions ==
{{breadcrumb1|Interface Customization}}


Place your user defined functions here to enhance MODs. Please follow the [[API:Empty Template|Example Function]] template for a clear layout. (I didn't find a better place to add this...I hope some users will find this a good idea and will add some of their own functions. So please feel free to add...)
These are cut-and-paste functions that you can use in your addons, submitted by WoWWiki contributors.


:'''Lore Functions''':
Please use [[Boilerplate: User Defined Function]] when submitting new functions.
: [[MOD_Lore SetLang|SetLang(Lang, ToParty, ShowParty)]] - This allows you to handle the different settings in Lore.
 
== String Functions ==
 
:[[GetWords]]("string")   - Split words on space boundary, return table
:[[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
 
== Table Functions ==
:[[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 ==
 
* [[:Category:HOWTOs]] - most have cut-and-pasteable code snippets


[[Category:Interface Customization]]
[[Category:Interface Customization]]
[[Category:World of Warcraft API| World of Warcraft API]]
[[Category:User Defined Functions| {{PAGENAME}}]]

Revision as of 10:07, 21 August 2006

Template: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.

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

Table Functions

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