WoW:Lua variable scoping: Difference between revisions

m
mNo edit summary
Line 179: Line 179:
Sometimes it is necessary to use a global version of a variable instead of a local copy which may exist. Luckily, Lua provides a mechanism to do this. In general, it won't be necessary if you follow programming best-practices, but occasionally it can be useful to use. Lua provides two methods to obtain a global variable:
Sometimes it is necessary to use a global version of a variable instead of a local copy which may exist. Luckily, Lua provides a mechanism to do this. In general, it won't be necessary if you follow programming best-practices, but occasionally it can be useful to use. Lua provides two methods to obtain a global variable:
#The [[API_getglobal|getglobal]]() function
#The [[API_getglobal|getglobal]]() function
#The _G table
#The [[Dump_G|_G]] table


=== The [[API_getglobal|getglobal]]() function ===
=== The [[API_getglobal|getglobal]]() function ===
Anonymous user