Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat | DONATE
Code dependencies — Gideros Forum

Code dependencies

totebototebo Member
edited November 2015 in General questions
Question to the floor: Are code dependencies actually needed in Gideros?

The way I see it all classes and files in the library will be used, so if all of them were added as dependencies of init.lua or Main.lua, that wouldn't be a problem. Is there a performance issue, or something else, that makes code dependencies actually useful in some way?
My Gideros games: www.totebo.com


  • hgy29hgy29 Maintainer
    It helps lua load your files in the right order. init.lua is always loaded first and main.lua is loaded last, but without dependancies other files could be loaded in any order, meaning that if B.lua depends on something defined in A.lua and B.lua is parsed first, then it won't find what it needs.
  • Yes, basically except init.lua and main.lua all other files are loaded in alphabetical order, upper case first, then lowercase.

    So if you have conf.lua with some setting, and you want to use these settings, where one of the settings is default scene transition, which references SceneManager class, it would fail, and you need to set scenemanager.lua as conf.lua dependency
  • Thanks guys. What is the benefit of this, though? What would the problem be if everything was loaded before any code was executed?

    Maybe because each class file takes a little while to load into memory, so you have the option to show something immediately before they're loaded into memory? To my knowledge large files (sprite sheets, music) are loaded first anyway, so, to me, this doesn't make much difference.
    My Gideros games: www.totebo.com
  • hgy29hgy29 Maintainer
    Hi @totebo,

    Every code you put in a lua file is executed as soon as it is parsed (loaded), that is when the code in in global scope, hence the issue.
  • Boom! Now that makes sense. Thanks for clarifying! :)

    The reason I asked in the first place was that one of my classes responsible for showing iAds was used as a fallback to Admob. Since Admob is so good at filling banners, I never noticed there was a problem with iAds until the game was live. It was a dependency issue, so easy to fix, but made me think if I could have avoided the issue or spotted it earlier.
    My Gideros games: www.totebo.com
Sign In or Register to comment.