[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Locals in Lua Environments
- From: Romulo Bahiense <romulo@...>
- Date: Mon, 28 May 2007 18:43:29 -0300
Luís Santos wrote:
Hello, People
Hi,
Your problem is that local variables are not accessed via function's
environment. You have to use the debug library to do so:
function foo( a, b )
local z = a + b
bar()
end
function bar( )
print( debug.getlocal( 2, 1 ) ) --> a 4
print( debug.getlocal( 2, 2 ) ) --> b 5
print( debug.getlocal( 2, 3 ) ) --> z 9
print( debug.getlocal( 2, 4 ) ) --> nil
end
foo( 4, 5 )
Please refer to Lua's documentation about debug.getlocal (and it's
friends: debug.setlocal and debug.getinfo)
--rb