Hi guys!
I have appConfig.lua file that contains:
return {
adTestingEnabled=false,
forceDefaultSettings=false,
--etc...
} |
And I have this line of code in my main.lua:
APP_CONFIG=require("appConfig") |
It works on gideros emulators (both PC and mobile).
BUT it crashes after packaging apk.
OMG it's so ugly, I came to know that it broke my release version for 10 days already and I didn't even know about it. App fell down in keyword rankings.
Why does working with gideros have to be so ugly?
How do we properly require such files?
Comments
It looks like it works in the player but in reality your file is loaded and executed twice. During export, gideros merges all lua files that have not been excluded into a single one, so require doesn’t work anymore.
Last note, always check your exported packages before pushing them to the stores. A player is close to the real thing, but has some specific code and initialization to make it communicate with the studio, obviously, and is not 100% the same as the autonomous version.
https://github.com/gideros/gideros/commit/595d346fa8602fa88634fe73a1eafa8fdf146229
Likes: MoKaLux, SinisterSoft, Apollo14
"What one programmer can do in one month, two programmers can do in two months." - Fred Brooks
“The more you do coding stuff, the better you get at it.” - Aristotle (322 BC)
- do as you initially did, but mark your setting file ‘exclude from execution’
- Or just make its file name not ending in .lua and use dofile() to load it
- Use the dependency graph to have the settings file loaded first (I still need to check if it actually works)
Likes: Apollo14
https://github.com/MultiPain/Gideros_examples/blob/master/CraftTileClone/assets/init.lua
https://github.com/MultiPain/Gideros_examples/blob/master/CraftTileClone/assets/main.lua
I think "exclude from execution" will work well
I've also tried dofile("appConfig.txt"), but when we edit txt files in Gideros there's no convenient syntax highlight, editing lua-files is much more pleasant.
"What one programmer can do in one month, two programmers can do in two months." - Fred Brooks
“The more you do coding stuff, the better you get at it.” - Aristotle (322 BC)
--!NOEXEC
Likes: SinisterSoft, Apollo14