View Single Post
03-22-24, 10:38 AM   #7
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,894
After the gobal has been created you can alway do

Code:
local db = MyVeryLongGlobaVariableName
When using tables, making changes to the local eg.

Code:
db.SomeVariable = "SomeThing New"
Will change the entry in the MyVeryLongGlobaVariableName table.

With other simple types (strings, numbers etc.) changing the local variable won't change the global.

Global names don't have to be uber long, just unique. The addon (folder) name will always be unique (or acronym with something like _DATA after it.)

locals are scope restricted so a local defined in anything the ends with an END (if, function etc.) will only be available in that scope.
Code:
local a = 2
print(a) -- prints 2
if 1 == 1 then
    print(a) -- prints 2
    local a = 3
    print(a) -- prints 3
end
print(a) -- prints 2, back to original "scope"
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 03-22-24 at 10:48 AM.
  Reply With Quote