WoW:Lua variable scoping: Difference between revisions

m
no edit summary
mNo edit summary
mNo edit summary
Line 1: Line 1:
{{tocright}}
{{breadcrumb2|Interface Customization|Lua}}
[[Addons]] in World of Warcraft share a single [[execution environment]]. As a result, all addons have access to the same global variables. If one addon creates a global variable named "foo," then all other addons can use (or overwrite) that same variable. This allows for some really useful things to happen; the most frequently used tactic that takes advantage of this feature is [[HOWTO:_Hook_a_Function|hooking]]. Unfortunately, this can also cause some problems in addons. They will conflict if they both try to use the same name for a variable. As a result, addon authors must ensure that their addons don't conflict by doing one (or more) of the following:
[[Addons]] in World of Warcraft share a single [[execution environment]]. As a result, all addons have access to the same global variables. If one addon creates a global variable named "foo," then all other addons can use (or overwrite) that same variable. This allows for some really useful things to happen; the most frequently used tactic that takes advantage of this feature is [[HOWTO:_Hook_a_Function|hooking]]. Unfortunately, this can also cause some problems in addons. They will conflict if they both try to use the same name for a variable. As a result, addon authors must ensure that their addons don't conflict by doing one (or more) of the following:
#Using assuredly-unique names for variables, such as MyAddon_MyFrame_OnLoad
#Using assuredly-unique names for variables, such as MyAddon_MyFrame_OnLoad
Anonymous user