Adding a Runtime Listener from an external module

Hi everyone, 

I’m working with functions in an external module (we’ll call it globalFunctions.lua) and I’ve noticed that you can’t add runtime listeners to objects from the external module.  Here’s the general layout of my external module and how I’m requiring it in the main.lua.

-globalFunctions.lua-

[lua]

–globalFunctions.lua

local M = {}

local function move(object)

     object.x = object.x - 10

end

M.move = move

local function addListener(object)

     object.enterFrame = move

     Runtime:addEventListener(“enterFrame”, object)

end

M.addListener = addListener

return M

[/lua]

We’re going to assume that the object the listener will be added to is already created.

[lua]

–main.lua

local gFunc = require(“globalFunctions”)

–Assume the creation of the object is here–

gFunc.addListener(object)

[/lua]

I know that the above code won’t work but is there a way I could possibly pass in the stage Runtime as a parameter for this?  So it would look something like this.

[lua]

–globalFunctions.lua

local M = {}

local function move(object)

     object.x = object.x - 10

end

M.move = move

local function addListener(object, Runtime )

     object.enterFrame = move

     Runtime:addEventListener(“enterFrame”, object)

end

M.addListener = addListener

return M

[/lua]

And then the call in the main.lua would look like this.

[lua]

–main.lua

local gFunc = require(“globalFunctions”)

–Assume the creation of the object is here–

gFunc.addListener(object, Runtime )

[/lua]

Is something like this feasible? If not is there a way to actually add listeners to objects from external modules? Also, if there are any other issues with the above code it would help me beyond belief if someone could point it out.

Thanks a ton!!