Can I require "package.file" instead of "package/file.lua"?
Re: Can I require "package.file" instead of "package/file.lua"?
sroccaserra, I was having this problem too. Thanks a bunch for the loader!
- bartbes
- Sex machine
- Posts: 4946
- Joined: Fri Aug 29, 2008 10:35 am
- Location: The Netherlands
- Contact:
Re: Can I require "package.file" instead of "package/file.lua"?
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)
Furthermore, you replied to a year-old thread, that's like humping a dead body! (joke, in case anyone gets offended)
-
- Prole
- Posts: 15
- Joined: Fri Mar 05, 2010 6:56 am
Re: Can I require "package.file" instead of "package/file.lua"?
Please help, i am trying to make a package to use with love, but i have to add this
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.
Code: Select all
package.path = '.\\?\\?.lua;' .. package.path
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.
- Attachments
-
- cel.love
- (903.14 KiB) Downloaded 120 times
Re: Can I require "package.file" instead of "package/file.lua"?
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 thismatthewburk wrote:Please help, i am trying to make a package to use with love, but i have to add this
or my require fails. This only fails when running from a .love file.Code: Select all
package.path = '.\\?\\?.lua;' .. package.path
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.
Code: Select all
require("my/file")
Code: Select all
require("my.file")
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: Can I require "package.file" instead of "package/file.lua"?
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.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.
So anything involving package.path is not going to work for your players.
Help us help you: attach a .love.
-
- Prole
- Posts: 15
- Joined: Fri Mar 05, 2010 6:56 am
Re: Can I require "package.file" instead of "package/file.lua"?
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
Who is online
Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 2 guests