On May 16, 2006, at 04:49, Vineet Jain wrote:

>

>> I need to find out (dynamically) if a certain lua module has some

>> functions and variables defined. I also need to set some module

>> variables (dynamically).

> After some googling I came across _G, is this how you can check if a

> function/variable exists in a lua module? Can you also use this to

> dynamically assign variables to lua modules?

_G is the current environment.

And as mentioned by Romulo, a module is a table. Lookup the key you are

after to check for membership:

local math = require( "math" )

if type( math.abs ) ~= "function" then

math.abs = function() end

end

if math.PI == nil then

math.PI = 3.14159265

end

Cheers

--

PA, Onnay Equitursay

http://alt.textdrive.com/