Subdirectories in .love Files
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Subdirectories in .love Files
My game is big enough that I started organizing it into subdirectories. It works just fine in a directory, but once I zip it into a .love file "require("subdir/something")" stops working. It looks like the LOVE filesystem can't deal with directories- the last line of the error is "no file "subdir/something.lua" in LOVE game directories." Any suggestions?
- kikito
- Inner party member
- Posts: 3153
- Joined: Sat Oct 03, 2009 5:22 pm
- Location: Madrid, Spain
- Contact:
Re: Subdirectories in .love Files
I'm pretty experienced putting things in subdirectories. If you upload a sample .love file somewhere I can give it a look.
As a blind guess, make sure that you are using the same uppercase-lowercase combinations on your repositories and files.
For windows, a file called Main.LUA is the same as a file called main.lua. For the zip control, it isn't.
As a blind guess, make sure that you are using the same uppercase-lowercase combinations on your repositories and files.
For windows, a file called Main.LUA is the same as a file called main.lua. For the zip control, it isn't.
When I write def I mean function.
Re: Subdirectories in .love Files
I checked the case already; here's the .love file:
- Jasoco
- Inner party member
- Posts: 3727
- Joined: Mon Jun 22, 2009 9:35 am
- Location: Pennsylvania, USA
- Contact:
Re: Subdirectories in .love Files
I get the same problem. If I unzip your uploaded version and run it as a package (i.e. as a folder with files) it runs fine. But when I rezip the files the way they would be for a finalized project, it gives the error again with a bunch of error jibberish...
Code: Select all
boot [string "world.lua"]:1: module 'world/sky' not found:
no field package.preload['world/sky']
no file './world/sky.lua'
no file '/usr/local/share/lua/5.1/world/sky.lua'
no file '/usr/local/share/lua/5.1/world/sky/init.lua'
no file '/usr/local/lib/lua/5.1/world/sky.lua'
no file '/usr/local/lib/lua/5.1/world/sky/init.lua'
no file './world/sky.so'
no file '/usr/local/lib/lua/5.1/world/sky.so'
no file '/usr/local/lib/lua/5.1/loadall.so'
no file "world/sky.lua" in LOVE game directories.
stack traceback:
[string "boot.lua"]:833: in function 'error_printer'
[string "boot.lua"]:768: in function <[string "boot.lua"]:766>
[C]: in function 'require'
[string "world.lua"]:1: in main chunk
[C]: in function 'require'
[string "main.lua"]:1: in main chunk
[C]: in function 'require'
[string "boot.lua"]:282: in function <[string "boot.lua"]:215>
[C]: in function 'xpcall'
[string "boot.lua"]:838: in main chunk
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: Subdirectories in .love Files
The problem is here:
Zooming in:
/
It works if you use "folder.module", since Lua uses a dot to refer to subdirectories when requiring.
Code: Select all
import "folder/module"
/
It works if you use "folder.module", since Lua uses a dot to refer to subdirectories when requiring.
Help us help you: attach a .love.
- kikito
- Inner party member
- Posts: 3153
- Joined: Sat Oct 03, 2009 5:22 pm
- Location: Madrid, Spain
- Contact:
Re: Subdirectories in .love Files
I respectfully disagree with our leader Robin.
I think the problem is that you have a folder called 'world' and also a file called 'world.lua'.
LÖVE doesn't seem to like that very much.
I tried renaming world.lua to World.lua, modified the require on main.lua and the generated .love worked. A slightly better suggestion: move it inside world/world.lua (and maybe move all those 'requires' to a specific file, i.e. world/init.lua).
By the way, your game rocks! It reminds me of my pew-pew-boom game, but better looking. Nice!
I think the problem is that you have a folder called 'world' and also a file called 'world.lua'.
LÖVE doesn't seem to like that very much.
I tried renaming world.lua to World.lua, modified the require on main.lua and the generated .love worked. A slightly better suggestion: move it inside world/world.lua (and maybe move all those 'requires' to a specific file, i.e. world/init.lua).
By the way, your game rocks! It reminds me of my pew-pew-boom game, but better looking. Nice!
When I write def I mean function.
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: Subdirectories in .love Files
Damn, I thought it worked, but I tested it more thoroughly and it seems you are right.kikito wrote:I respectfully disagree with our leader Robin.
And I am not your leader.
Help us help you: attach a .love.
Re: Subdirectories in .love Files
Thanks for the help, everyone.
Switched to dots for aesthetic purposes, but that wasn't the problem. In main.lua, require("world.init") works (although it would be nice if require("world") checked for "world.init" by default like Lua; should I submit that as a feature request?). However, world/init.lua errors when I require("world.sky") but works with require("world/sky"), which is even weirder because all the other requires work with dots.
Switched to dots for aesthetic purposes, but that wasn't the problem. In main.lua, require("world.init") works (although it would be nice if require("world") checked for "world.init" by default like Lua; should I submit that as a feature request?). However, world/init.lua errors when I require("world.sky") but works with require("world/sky"), which is even weirder because all the other requires work with dots.
- kikito
- Inner party member
- Posts: 3153
- Joined: Sat Oct 03, 2009 5:22 pm
- Location: Madrid, Spain
- Contact:
Re: Subdirectories in .love Files
I experienced some weirdness on that regard.
In PÄSSION, I allways use the following:
Robin:
In PÄSSION, I allways use the following:
- Relative paths don't seem to work. If you are inside foo/bar.lua and you want to require foo/baz.lua, you have to write foo/ again.
- I allways use / instead of . , just because empirically it gave me less trouble (the dot got confused when parsing zipped files in some occasions, while the slash didn't)
- I very often include the .lua file extension at the end
Robin:
Napoleon Bonaparte wrote:A leader is a dealer in hope
When I write def I mean function.
Re: Subdirectories in .love Files
Yeah, I'll go with slashes for now. I'm posting a bug report.
Who is online
Users browsing this forum: Google [Bot] and 2 guests