Page 1 of 2

Subdirectories in .love Files

Posted: Wed May 05, 2010 1:56 pm
by Rusky
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?

Re: Subdirectories in .love Files

Posted: Wed May 05, 2010 4:30 pm
by kikito
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.

Re: Subdirectories in .love Files

Posted: Wed May 05, 2010 5:51 pm
by Rusky
I checked the case already; here's the .love file:
distoban.love
(384.7 KiB) Downloaded 248 times

Re: Subdirectories in .love Files

Posted: Wed May 05, 2010 7:50 pm
by Jasoco
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

Re: Subdirectories in .love Files

Posted: Wed May 05, 2010 7:56 pm
by Robin
The problem is here:

Code: Select all

import "folder/module"
Zooming in:
/
It works if you use "folder.module", since Lua uses a dot to refer to subdirectories when requiring.

Re: Subdirectories in .love Files

Posted: Wed May 05, 2010 9:35 pm
by kikito
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!

Re: Subdirectories in .love Files

Posted: Wed May 05, 2010 10:31 pm
by Robin
kikito wrote:I respectfully disagree with our leader Robin.
Damn, I thought it worked, but I tested it more thoroughly and it seems you are right. :death:

And I am not your leader.

Re: Subdirectories in .love Files

Posted: Wed May 05, 2010 10:41 pm
by Rusky
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.

Re: Subdirectories in .love Files

Posted: Wed May 05, 2010 10:58 pm
by kikito
I experienced some weirdness on that regard.

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
Here's my passion/init.lua file as a reference. The paths would look nicer without the file extensions and so many slashes, but it was just the only way I could make the thing work.

Robin:
Napoleon Bonaparte wrote:A leader is a dealer in hope

Re: Subdirectories in .love Files

Posted: Wed May 05, 2010 11:17 pm
by Rusky
Yeah, I'll go with slashes for now. I'm posting a bug report.