WoW:Lua variable scoping: Difference between revisions

Line 182: Line 182:


=== The [[API_getglobal|getglobal]]() function ===
=== The [[API_getglobal|getglobal]]() function ===
==== NOTE AS OF PATCH 4.0.1 getlobal() is depreciated and won't work for WOW addons. Use the _G global table methods discussed in the next section. [Also applies to setglobal()]
A function provided by the Lua language is [[API_getglobal|getglobal]](). It does precisely what its name states -- it retrieves a global variable and returns it. To use this function, you pass in a string representation of its name:
A function provided by the Lua language is [[API_getglobal|getglobal]](). It does precisely what its name states -- it retrieves a global variable and returns it. To use this function, you pass in a string representation of its name:


Anonymous user