Page 2 of 2
Re: Can I require "package.file" instead of "package/file.lua"?
Posted: Mon Mar 08, 2010 6:11 pm
by willurd
sroccaserra, I was having this problem too. Thanks a bunch for the loader!
Re: Can I require "package.file" instead of "package/file.lua"?
Posted: Mon Mar 08, 2010 6:14 pm
by bartbes
Ehm.. sorry to break it to you, but this functionally is part of love... (now)
Furthermore, you replied to a year-old thread, that's like humping a dead body! (joke, in case anyone gets offended)
Re: Can I require "package.file" instead of "package/file.lua"?
Posted: Tue Mar 09, 2010 7:44 am
by willurd
Ah, I did, didn't I
Re: Can I require "package.file" instead of "package/file.lua"?
Posted: Wed Mar 17, 2010 8:27 am
by matthewburk
Please help, i am trying to make a package to use with love, but i have to add this
Code: Select all
package.path = '.\\?\\?.lua;' .. package.path
or my require fails. This only fails when running from a .love file.
Actually it seems my hack only works if i my .love file is in the same directory that its contents are in, if that makes any sense.
Re: Can I require "package.file" instead of "package/file.lua"?
Posted: Wed Mar 17, 2010 9:45 am
by willurd
matthewburk wrote:Please help, i am trying to make a package to use with love, but i have to add this
Code: Select all
package.path = '.\\?\\?.lua;' .. package.path
or my require fails. This only fails when running from a .love file.
Actually it seems my hack only works if i my .love file is in the same directory that its contents are in, if that makes any sense.
If I understand you correctly, I was having the same problem. I just switched from using dots to slashes, so for "my/file.lua", try this
instead of this
That fixed my problem.
Re: Can I require "package.file" instead of "package/file.lua"?
Posted: Wed Mar 17, 2010 8:42 pm
by Robin
matthewburk wrote:Actually it seems my hack only works if i my .love file is in the same directory that its contents are in, if that makes any sense.
It makes sense, because package.path is Lua's search path, not LÖVE's. For some reason, LÖVE still lets Lua handle require()s if it can't find the file itself.
So anything involving package.path is not going to work for your players.
Re: Can I require "package.file" instead of "package/file.lua"?
Posted: Thu Mar 18, 2010 7:36 am
by matthewburk
Ok, i worked it out, although its not ideal. Basically I have to move the main module of my package outside of the folder for love to see it. All the submodules in the package can stay in the folder. It would be nice if love supporeted the main module in the package folder like stock lua. Makes distributing lua packages for love easier, and love is all about great distribution