Showcase your libraries, tools and other projects that help your fellow love users.
Robin
The Omniscient
Posts: 6506 Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:
Post
by Robin » Wed Sep 21, 2011 9:11 pm
A good way to approach this is to look at where the variable is used, and look upwards, and up indentation levels.
You stop when you see:
local var : it is a local variable
for var = 1, 10 do or for var in somegenerator() do : it is a local variable
function bluh(var, bluh) : it is a local variable
You are at the start of the file: it is a global variable
Example:
Code: Select all
function a (shazam)
function b()
print(shazam) -- a local variable, to be exact the argument to a
end
end
Although there's more to it, what I just described is the gist of it.
pancakepalace
Prole
Posts: 40 Joined: Wed Aug 03, 2011 3:13 pm
Post
by pancakepalace » Wed Sep 21, 2011 9:36 pm
Thanks for the help. Iv'e updated the code to reflect this cleaner writing.
miko
Party member
Posts: 410 Joined: Fri Nov 26, 2010 2:25 pm
Location: PL
Post
by miko » Wed Sep 21, 2011 11:26 pm
pancakepalace wrote: All lua types are supported except functions and userData. If someone knows how to support functions by writing them out as strings, that would be great. I'm not even sure if it's possible.
If you have access to the source files, you could try:
and then read the relevant lines from the file.
kikito
Inner party member
Posts: 3153 Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:
Post
by kikito » Thu Sep 22, 2011 8:40 am
I'm also going to put a link to my
inspect.lua in case it serves you.
It doesn't do "function dumping", but it numbers functions, tables, etc so they can be told apart easily. It also has a good deal of tests.
When I write def I mean function .
pancakepalace
Prole
Posts: 40 Joined: Wed Aug 03, 2011 3:13 pm
Post
by pancakepalace » Thu Sep 22, 2011 3:10 pm
That's really cool! Your code looks more powerful than mine. I'm sure I'll find a use for it. Thanks.
Users browsing this forum: No registered users and 1 guest