Variables

Posted by Siris on Mon 27 Sep 2010 01:02 AM — 3 posts, 13,236 views.

#0
Is there a way to see all the variables you have created and set in LUA? Like a command that would list them all then the values.

ListVars

Var1 = "This is variable One"
Var2 = "This is Variable Two"
ect.

I'd like to list all my variables so I can find out which ones I need to turn into global variables to carry over to my next session.
USA #1
You can do the following to see all of your global variables:

require "tprint"
tprint(_G)


However, this includes all of the world functions and a number of other things, including the tprint() function that you just loaded up. In other words, this is probably not the best way to tell which variables you want to save. :)
Australia Forum Administrator #2
Your best bet is to make a table and put the variables in it.

eg.


myvars = {}

myvars.Var1 = "hello"
myvars.Var2 = "world"


Then you can just serialize myvars (there is a thread about doing just that) in a single operation.