View Single Post
11-11-11, 05:09 AM   #7
SaraFdS
A Fallenroot Satyr
 
SaraFdS's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 24
Originally Posted by ballagarba View Post
Hmm, correct me if I'm wrong but couldn't you just imitate the _G with a local version, since as far as I understand, _G is just a table.
Effectively that's what I've done in my workaround (just different variable names), seems you got that idea faster than I did
Originally Posted by suicidalkatt View Post
I think what you're trying to say, is there a different way of getting the global variable without using this?
Lua Code:
  1. _G["varname"]

In the usage you're describing, no.
No, I was looking for a way to get a local variable, similar to how you use _G to get a global variable.
Originally Posted by SDPhantom View Post
As for a true Lua global, there's no way to define or read dynamic locals. However as you've demonstrated, you may define a single local table that holds additional data as key/value pairs. I would advise against this unless absolutely necessary as table entries consume more resources than locals themselves. I follow the simple rule, tables are only for list/structure data, everything else is to stay in locals.
So, it'd be faster and more efficient to hardcode everything that needs to be done for each local, instead of putting them into a table and iterating over it?
__________________
Sará the Insane
  Reply With Quote