Page 1 of 1

Where do I set up a global variable?

Posted: Sun Jul 09, 2017 2:08 am
by jenx
I need a global variable accessible by all functions. Just the one!

Where in my add on should I place

my variable = 15

?

Re: Where do I set up a global variable?

Posted: Sun Jul 09, 2017 10:18 am
by darkgod
you cna define it form anywhere, i'd say the load hook though, and you make one explicitly this way: _G.foo = bar

Re: Where do I set up a global variable?

Posted: Sun Jul 09, 2017 3:51 pm
by jenx
darkgod wrote:you cna define it form anywhere, i'd say the load hook though, and you make one explicitly this way: _G.foo = bar
Thanks.

After a bit of experimenting, I realised I had to call it every time as _G.foo (duh!), not just foo.