I thought this one is an easy one, but now I’m trying to access this for about an hour and can’t figure it out.
Here is my problem:
I have an external module, like this one…
local M = {} local innerfunction -- functions are now local: local testFunction1 = function() print( "Test 1" ) -- now the function I want to access later innerfunction = function (event) -- my inner function code end -- assign a reference to the above local function M.testFunction1 = testFunction1 M.innerfunction = innerfunction -- Finally, return the table to be used locally elsewhere return M
Now I want to access not only testFunction1 which I can easily by doing this…
local example = require "examplemodule" example.testFunction1() -- prints "Test 1" to terminal
Instead I want to access innerfunction directly, like for example with a Runtime listener in the main code.
How can this be done?
My first guess was to do this:
local example = require "examplemodule" Runtime:addEventListener ("touch",example.innerfunction)
But with this code I get an error.
Is there a way to access this kind of ‘nested’ functions in a module?
Any help welcome!
Best,
Daniela