Reply
Thread Tools Display Modes
Unread 08-11-11, 11:32 AM   #1
chrixian
Zombie
Join Date: Aug 2011
Posts: 1
WoW's Global Function Aliases

I posted this on the official addon forum, figure I'd repost here.

I was getting annoyed with random errors anytime I'd use function aliases I was used to having available so I re-created all the global aliases that WoW provides. I figured I'd post it because it could be helpful to anyone porting any addons to Rift. I personally have the code as the first file in my RunOnStartup but you could make a lib out of it and add it as a dependency/embed if you were so inclined.. would probably make it a bit more reusable. shrug. anyway here ya are

Code:
    if not abs then abs = math.abs end
    if not gsub then gsub = string.gsub end
    if not ceil then ceil = math.ceil  end
    if not strbyte then strbyte = string.byte end
    if not cos then cos = math.cos end
    if not strchar then strchar = string.char end
    if not deg then deg = math.deg end
    if not strfind then strfind = string.find end
    if not exp then exp = math.exp end
    if not strlen then strlen = string.len end
    if not floor then floor = math.floor end
    if not strlower then strlower = string.lower end
    if not frexp then frexp = math.frexp end
    if not strmatch then strmatch = string.match end
    if not ldexp then ldexp = math.ldexp end
    if not strrep then strrep = string.rep end
    if not log then log = math.log end
    if not strrev then strrev = string.reverse end
    if not max then max = math.max end
    if not strsub then strsub = string.sub end
    if not min then min = math.min end
    if not strupper then strupper = string.upper end
    if not mod then mod = math.fmod end
    if not foreach then foreach = table.foreach end
    if not rad then rad = math.rad end
    if not foreachi then foreachi = table.foreachi end
    if not random then random = math.random end
    if not getn then getn = table.getn end
    if not randomseed then randomseed = math.randomseed end
    if not sort then sort = table.sort end
    if not sqrt then sqrt = math.sqrt end
    if not tinsert then tinsert = table.insert end
    if not format then format = string.format  end
    if not tremove then tremove = table.remove end
    if not gmatch then gmatch = string.gmatch end
chrixian is offline   Reply With Quote
Unread 10-02-11, 05:07 AM   #2
Neglected
Bomani Harbinger
AddOn Author - Click to view addons
Join Date: Jun 2011
Posts: 5
Couldn't you just use:
Code:
 local abs = math.abs
Instead? First you only use index the functions you need, you don't pollute the global namespace and (apparently) indexed locals are faster than globals.
__________________
Quote:
<+Nobgul> Only a real man can appreciate pink
Neglected is offline   Reply With Quote
Reply

Go BackRiftui » Developer Discussions » Tutorials & Other Helpful Info. » WoW's Global Function Aliases

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off