Coming from Corona i love the freedom and flexibility of Gideros. However, there is one thing I can't wrap my head around. What is the purpose of "executing" all the lua files of our app before the app truly starts? Does this happen only in the simulator? What happens if I have 2 files, a main.lua and an addon.lua and I check "do not execute" for addon.lua but then require it within main.lua? Id be glad if someone could explain this to me as the gideros documentation doesn't seem to delve deep enough into this topic. Thanks!
Comments
We can assume that the order of execution is pretty random, but there are two things guaranteed:
init.lua will always be executed first
main.lua will always be executed last
So the best practice is:
to add all additional functionality and modifications to existing classes in init.lua
do all initialization of app etc in main.lua (when all other code was already loaded)
wrap the code in any other lua file in a scope as function, yet better create each lua file as a separate Gideros class, either it will be a scene shown in scene manager or some simple object represented by class, but there should not be some plain code executed in these files, only in main.lua.
Thats the oop approach of Gideros.
But of course, thats all can be configured:
1) you can right click on any file and exclude it from execution, then it won't be executed automatically and you would have to require it.
2) you can set code dependencies between two files, that would mean that you can set for specific lua file to be executed automatically, but only when your other specified lua file will be already executed.
Hope that clears it up!
Likes: saeys, e2000
https://play.google.com/store/apps/developer?id=Into-It+Games
http://appstore.com/LidiaMaximova
But yes you are right.
Sometimes simple questions make great tutorials