Init.lua file in Android

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
Yjuq
Prole
Posts: 2
Joined: Sun May 19, 2019 2:09 am

Init.lua file in Android

Post by Yjuq » Sun May 19, 2019 2:59 am

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!

User avatar
slime
Solid Snayke
Posts: 2820
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: Init.lua file in Android

Post by slime » Sun May 19, 2019 3:35 am

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.

Yjuq
Prole
Posts: 2
Joined: Sun May 19, 2019 2:09 am

Re: Init.lua file in Android

Post by Yjuq » Sun May 19, 2019 4:29 am

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*

User avatar
raidho36
Party member
Posts: 1795
Joined: Mon Jun 17, 2013 12:00 pm

Re: Init.lua file in Android

Post by raidho36 » Sun May 19, 2019 5:30 am

It's not about programming languages. It's about NTFS not being case-sensitive by default (also being the default filesystem on Microsoft OSes).

Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests