WoW API: setglobal
Jump to navigation
Jump to search
Set a global variable, from a string.
setglobal( "globalName", value );
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 globalenv = getfenv(); local prevval = globalenv["MyVariable"]; -- "getglobal()" globalenv["MyVariable"] = 1234; -- "setglobal()"
Since calling a function always requires some extra overhead, it's most likely a better idea to not use setglobal and getglobal, but to use the global environment (as above) instead.