2017-02-24 82 views
0

因此,我剛剛安裝了Lua,Love2D,LuaJIT和Sublime Text與Lua/Love包。當我再嘗試運行這個小程序:嘗試運行Love2D應用程序時出錯

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

隨着CTRL+SHIFT+B,然後LuaLove - Run我得到這個錯誤:

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]] 

我認爲這是與我沒有把愛的正確的路徑變量。但它是這樣的:C:\Program Files\LOVE 我希望有人有一個解決方案。

回答

1

您正在運行您使用luajit解釋器的腳本,而不是LOVE可執行文件,這會觸發您看到的錯誤(因爲LuaJIT解釋器不知道任何關於love對象的任何內容)。您需要配置LuaLove以使用LOVE可執行文件;有關詳細信息,請參閱documentation中的此註釋: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.

相關問題