LuaEdit can not find the module when Lua files all in the same folder

advertisements

I downloaded LuaEdit to use as an IDE and debug tool however I'm having trouble using it for even the simplest things. I've created a solution with 2 files in it, all of which are stored in the same folder. My files are as follows:

--startup.lua

require("foo")

test("Testing", "testing", "one, two, three")

--foo.lua

foo = {}

print("In foo.lua")

function test(a,b,c) print(a,b,c) end

This works fine when in my C++ compiler when accessed through some embed code, however when I attempt to use the same code in LuaEdit, it crashes on line 3 require("foo") with an error stating:

module 'foo' not found:
no field package.preload['foo']
no file 'C:\Program Files (x86)\LuaEdit 2010\lua\foo.lua'
no file 'C:\Program Files (x86)\LuaEdit 2010\lua\foo\init.lua'
no file 'C:\Program Files (x86)\LuaEdit 2010\foo.lua'
no file 'C:\Program Files (x86)\LuaEdit 2010\foo\init.lua'
no file '.\foo.lua'
no file 'C:\Program Files (x86)\LuaEdit 2010\foo.dll'
no file 'C:\Program Files (x86)\LuaEdit 2010\loadall.dll'
no file '.\battle.dll'

I have also tried creating these files prior to adding them to a solution and still get the same error. Is there some setting I'm missing? It would be great to have an IDE/debugger but it's useless to me if it can't run linked functions.


The issue is probably that your Lua files are not on the path in package.path (for C files this is package.cpath).

My guess is that the LuaEdit program is not launched in the directory you have your files in, and hence does not have a match for eg .\foo.lua.

You have 3 simple solutions to this (from dumb to smarter):

  • Find out what path LuaEdit considers as ./ and put your files there.
  • Open up a terminal in the right directory (the one containing your files), and run LuaEdit from there.
  • Add the path the files are on to package.path and package.cpath before doing any require's