I'm pretty new to LUA coding.
And just have started a project called: Neon Fleet!
And as many others may have experienced, I ran into an obstacle...
My problem is:
I'm trying to make a scoreboard, but when W is pressed, it just keeps spamming the "score = score + 1" instead of just adding +1 every hit and release. So I guess the sleep is not even inplace, but I couldn't think of any other solution.
Conclusion:
I need a (shorter) code when a key is pressed, you have to wait 5 seconds before re-pressing it. (Repressing = not holding the button, but actually you need to re-press it after the 5 sec.)
this is the code I tried:
Code: Select all
if love.keyboard.isDown("w") then
score = score + 1
scoreToggle = 1
end
--Need a way to make the sleep only local, to execute the score toggle.
if scoreToggle == 1 then
love.timer.sleep ( 50*(dt))
print ("Hay!")
scoreToggle = 0
end
the whole game stops for a sec...
I hope someone can help me with my code,
or even knows a better and quicker way of doing it.
and already thanks for al yer support guys
I hope my question has been clear.
Greetings,
DiabetiMark ;p