Current / Active module name

Is there a way to get the currently active module name?

e.g. if I am in screen1.lua, how can I get this information

I have tried

n = package.loaded.name
n = package.loaded.modname

I have run out of ideas.
Does anyone know this please??

cheers

its active right as you require it

what are you trying to accomplish?

To get the various active modules loaded try this code:

1
2
3
for i,v in pairs(package.loaded) do
        print(i)
end

Hi
thx for replies.
Basically I have a module per screen in my app, and I have been manually passing module names between themselves for previous screen, next screen, destination screen etc. and was looking for a better way of doing it.

I will try the code you have posted and thx to you both for replies

If you wanted to pass the module names you can use the _G table.

In your main.lua file:
_G["yourVariableName"] = require("modulefileName")

then in your other lua files you can just access the module via _G["yourVariableName"] or you might want to localize it in each file, and then use that variable throughout your code, like:

local yourVariableName = _G["yourVariableName"]

thx again!

views:1382 update:2011/12/30 9:10:41
corona forums © 2003-2011