I have a feeling LOVE has changed how package loading works. Unlike Lua it requires the filename with an extension. As i move my code to and from LOVE and Lua environments I keep having to change my code.
In LOVE, require"module" fails to load module.lua
In Lua, require"module.lua" fails to load module.lua
require"module" behaviour
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: require"module" behaviour
What do you mean "in Lua"?
Re: require"module" behaviour
Lua as in not LOVE. Using the 5.1.4 command line interpreter to be exact.
Re: require"module" behaviour
I have only added a function to package.loaders which uses love.filesystem to find the file you're looking for. The standard package loaders still have precedence, so if require"module" fails, it's because Lua can't find the file ...
Re: require"module" behaviour
Well maybe LOVE's package loader is broke. Or, the embedded Lua in love is broke.
require"module" is supposed to work.
require"module" is supposed to work.
Re: require"module" behaviour
Take this folder structure
From my windows desktop dragging the folder temp onto love shortcut fails.
From the DOS shell specifying the folder name fails
> love.exe temp
but this works
> cd temp
> love.exe .
In all cases above using the filename extension will work, except in vanilla lua.
I can see the issue might have something to do with the current working directory. But that doesnt explain when using the extension why it does work.
In any case theres a workaround and ill change my workflow.
Thanks.
Code: Select all
\temp
\main.lua (contains require"module" line)
\module.lua
From the DOS shell specifying the folder name fails
> love.exe temp
but this works
> cd temp
> love.exe .
In all cases above using the filename extension will work, except in vanilla lua.
I can see the issue might have something to do with the current working directory. But that doesnt explain when using the extension why it does work.
In any case theres a workaround and ill change my workflow.
Thanks.
Re: require"module" behaviour
If you're working with modules written in lua maybe you could try dofile (with the extension).
Re: require"module" behaviour
Nothing is changed or broke, the added function to package.loaders just doesn't understand extension-less filenames.
Added to task list.
Added to task list.
Re: require"module" behaviour
Would it be possible to also return something from the module, if it returns something?
For example:
The standard 'require' function does return the value.
For example:
Code: Select all
-- xyz.lua ------
local val = "hello"
return val
-- main.lua -----
local val = love.filesystem.require "xyz.lua"
-- val is now nil, should be "hello"
Who is online
Users browsing this forum: No registered users and 1 guest