Module to talk to parent ?

In objc you would create delegates. So lets say i have in my main.lua file, this

Local b = require "mymodule"

Local d = b.new()

Then

Local e = d.getfile("dadada.txt")

I would like the getfile function to trigger a function inside the main.lua if the file downloads or fails, two different functions.

Is it as simple as both files requiring on another? I hope i am making myself understandable. I want my module to call a function in its parent

From my understanding of modules, they're like children to a parent. Not many languages let the children dictate to the parent. There are a few ways around this, one is to use a Setter/Getter type style like Action Scripts or, to fire off a custom event that's being listened for. I personally prefer setter/getters.

you aren't limited to any sort of parent/child relationship. You can set up access to whatever you may need.

Since you mention main.lua, you can delcare those functions that you need to use in other files as global functions, and they can be used directly without require from anywhere but the inside of a module that was declared without package.seall, and some usages of setenv() as well.

views:1596 update:2011/10/5 21:23:48
corona forums © 2003-2011