Reputation: 3
I started using LOVE yesterday and I'm trying to code a basic quit function with LUA.
Here's my code
if function love.keyboard.getKey("q")
function love.event.quit()
end
I've tried it with and without the functions. When I run it, it gives me this error
Error
Syntax error: main.lua:1: '(' expected near 'love'
Traceback
[C]: at 0x7ff9037828f0
[C]: in function 'require'
[C]: in function 'xpcall'
[C]: in function 'xpcall'
Upvotes: 0
Views: 296
Reputation: 28964
if function love.keyboard.getKey("q")
function love.event.quit()
end
Is invalid Lua syntax.
function is a keyword that is used to define function value. It is not part of the if statement and not used in function calls.
an if statement looks like
if condition then
-- block
end
love.keyboard.getKey("q")
is not part of the love2d API.
What you want to do would probably be achieved by implementing a keypressed event handler.
Computer programs are not written by guessing some syntax and then asking for help. Do a tutorial and read the Lua manual if you want to do anything useful with Lua.
Upvotes: 2