Ruben de Groot
Ruben de Groot

Reputation: 59

Error when trying to run a Love2D application

So I have just installed Lua, Love2D, LuaJIT, and Sublime Text with Lua/Love package. When I then try to run this little program:

function love.draw()
    love.graphics.print("Hello World", 400, 300)
end

With CTRL+SHIFT+Band then LuaLove - Run I get this error:

luajit: [path to program]\main.lua:1: attempt to index global 'love' (a nil value)
stack traceback:
    [path to program]\main.lua:1: in main chunk
    [C]: at 0x00402020
[Finished in 0.0s with exit code 1]
[cmd: ['luajit', '[path to program]\\main.lua']]
[dir: [path to program]]
[path: [every thing in path variable]]

I think it has something to do with that I didn't put Love the right way in the path variable. But it's in there like this: C:\Program Files\LOVE I hope someone has a solution.

Upvotes: 0

Views: 670

Answers (1)

Paul Kulchenko
Paul Kulchenko

Reputation: 26774

You are running the script you have using luajit interpreter, not LOVE executable, which triggers the error you see (as the LuaJIT interpreter doesn't know anything about love objects). You need to configure LuaLove to use the LOVE executable; see this note in the documentation for details: Both Sublime 2 and 3 require the directory of your LÖVE binary to be part of your PATH variable. You can avoid this by changing the "love" path in the build script. This is more complicated in Sublime 3..

Upvotes: 1

Related Questions