Hey,
I'm trying to structure things more nicely and having my interface files on require files that load in. Now im having difficulty access/ sharing out the functions from one to another.
I can call a function that is in menu_letters.lua from the main file (menu_letters.menuOut) but what I require is to call a function from the main file in the required module... so below I need to call menuOpen in the main file from the file that is being required... like using _parent in Flash...
How is this possible?
main.lua
1 2 3 4 5 6 | super = require("menu_letters") level = super:newMain() menuOpen = function( event ) transition.to(btn_menutab, { time = 500, rotation = 180 }) end |
@josh, just one little note from a development point of view.
the menu_letters.lua file is more like a library for you, right? because if that is how you look at it then there is a simple thing that I wanted to suggest.
you *never* have the library work with fixed elements/variable name, it has routines that get variable and objects passed to it to manage. this is in reference to the btn_menutab that is in your code, it is an absolute (hardcoded) variable.
if you do not look at it like a library, then you will have to look at the module(..., package.seeall) line at the start of your code. However adding that is also a choice that is up to you as there are some developers that prefer *not* to use that as it will be deprecated, no idea when, but deprecated for sure.
I use the module method and I wouldn't worry about it for now as when the time comes, my apps might have been updated several times over by then.
cheers,
?:)