WoW:User defined functions
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
- Category:HOWTOs - most have cut-and-pasteable code snippets