Error
Syntax error: main.lua:6: '=' expected near '+'
Traceback
[C]: at 0x52f6d550
[C]: in function 'require'
[C]: in function 'xpcall'
[C]: in function 'xpcall'
Error
Syntax error: main.lua:6: unexpected symbol near '+'
Traceback
[C]: at 0x52f6d550
[C]: in function 'require'
[C]: in function 'xpcall'
[C]: in function 'xpcall'
count = 0
function love.draw()
love.graphics.print(count, 400, 150)
end
function love.keypressed( key, scancode, isrepeat )
if scancode == "space" then
count = count + 1
end
end
Last edited by GVovkiv on Tue Jul 20, 2021 8:49 pm, edited 1 time in total.
count = 0
function love.draw()
love.graphics.print(count, 400, 150)
end
function love.keyboard.isDown(space) -- isDown needs string as argument, but you send it variable space (which in that case == nil), not string "space"
count + 1 -- lua doesn't support "=+", "=-", etc; only value = value + 1
end -- also, "love.keyboard.isDown()" it's not callback, it should be used in conditions:
love.update = function()
if love.keyboard.isDown("space") then
*something*
end
end
Last edited by GVovkiv on Tue Jul 20, 2021 8:48 pm, edited 3 times in total.