Quantcast API setglobal - WoWWiki - Your guide to the World of Warcraft
Recent changes Random page
GAMING
Gaming
 
StarCraft Wiki
Super Smash Wiki
Halopedia
Diablo Wiki
FFXIclopedia
Grand Theft Wiki
See more...

API setglobal

From WoWWiki

Jump to: navigation, search
Main Menu


Set a global variable, from a string.

setglobal( "globalName", value )

Contents

Parameters

Arguments

("globalName", value)
globalName 
String - Name of the global you want to change.
value 
Any - Value you want to set the global to.

Returns

Always returns nil.

Example

/script setglobal( "MyVariable", 1234 )

Result

MyVariable = 1234

Details

As of the introduction of getfenv() into the API, setglobal() and getglobal() are somewhat superfluous. You can always do something along the lines of:

 local _G = getfenv()
 local prevval = _G["MyVariable"]   -- "getglobal()"
 _G["MyVariable"] = 1234            -- "setglobal()"

Function calls always cost some overhead, so if a large number of getglobal calls are being made, the getfenv table will be a faster route. Note that for few or infrequent calls the performance gain of this method is negligible.

Rate this article:
Share this article: