Page 1 of 1

Init.lua file in Android

Posted: Sun May 19, 2019 2:59 am
by Yjuq
Hello o/

I had an issue with starting a love file under Android. It couldn't find the library that I wanted to require. After some testing I figured out that you can't load the Init.lua for a module. For example, that's my filetree:

main.lua
-- mylib
---- Init.lua
---- somestuff.lua

The main.lua contains something like this:
require("mylib")

normally it will find the Init.lua in the mylib folder and require this file instead. But if you put the stuff into a *.love file it doesn't do it anymore. So - I can't use the library in Android as well. Why is this the case? What can I do to archiv this behavior?

I already tried to change the package.path variable and the same with the love.filesystem.setRequirePath() function. I wrote something like that in the top of my main file:

love.filesystem.setRequirePath("?.lua;?/init.lua;./?.lua;./?/init.lua;")
package.path = love.filesystem.getRequirePath() .. package.path

This solved my problem for the windows love file, but not for android. Any suggestions? I really don't want to change every require call to require("mylib.Init"). Any suggestions?

Sorry for my bad english, I tried to explain my issue as good as I could. Thank you for your time!

Re: Init.lua file in Android

Posted: Sun May 19, 2019 3:35 am
by slime
init.lua shouldn't be capitalized. The windows filesystem isn't case sensitive so the problem can't be detected when your game is a plain folder there, but once it's been zipped into a .love (or if it's a plain folder on case-sensitive filesystems such as in Linux), then it matters.

Re: Init.lua file in Android

Posted: Sun May 19, 2019 4:29 am
by Yjuq
I can't believe that... After around 9 years experience with different programming languages... And then I do such a banal mistake...
Yes, I forget about that and was trying around 6 hours now to figure out how to load the modules...

Thank you - and shame on me *facepalm*

Re: Init.lua file in Android

Posted: Sun May 19, 2019 5:30 am
by raidho36
It's not about programming languages. It's about NTFS not being case-sensitive by default (also being the default filesystem on Microsoft OSes).