View Single Post
03/24/14, 01:37 PM   #6
Vuelhering
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 169
Originally Posted by Yssaril View Post
Its usually best to stay away from creating globals. Less risk of other addons messing with yours and faster variable access
Is there a way to scope a variable to only your addon (across several Lua files) without making it global?

Something like...

file1:
local X=555
setup-file2(&X)
X = 444
print X => 444

file2:
local X
function setup-file2(&Y)
X = &Y
end
print X => 444 --after setting it in file1


I don't remember there being any way to equivalence two differently-scoped variables like that in Lua without doing something like a function. But calling a function would probably be slower than using a global.

Last edited by Vuelhering : 03/24/14 at 01:47 PM.
  Reply With Quote