Another noob question (I tried to define some macros for debugging and execute them before everything else executes). It works by having a file Constants.lua and declaring dependencies. Then I finally got the Games on Gideros book (awesome, btw) and learned about init.lua, and did some research.
Based on my understanding is that init.lua is loaded first, main.lua last. Also, each file is executed after it's loaded and parsed. So in the single lua file on deployment the init.lua code would be on top, and the main.lua code on the bottom. But that's not what I see (with the windows player locally as well as pushing to the android player from windows). What am I missing?
What I did: I created a file init.lua with a single line of code
I put similar lines in other files. The result is
Bushido Battle Started.
Uploading finished.
Constants.lua
init.lua
main.lua |
init.lua doesn't depend on anything.
main.lua has to depend on SceneManager to work, so it does that. (I have Scenemanager.lua among my class files, not using the plugin)
Comments
Also those rules about main.lua and init.lua only apply to top level files, if you put them in sub directories, they lose their specificities.
Likes: SinisterSoft
If I move them to the top level directory, then init.lua gets run first, and main.lua gets run last without declaring any dependencies (as expected).
A minor question: Right-click Refresh doesn't find main.lua and init.lua in the top directory. I have to manually link them "add existing file". Is this expected behavior?
Also, it would be nice if it applies to files in subdirectories, too, so they don't clutter the top directory. Could that be a feature request?
I think changing it would also likely break a lot of existing projects.
I submitted a pull request to the documentation. Let me know if this is helpful.
https://github.com/gideros/gideros/pull/490