local dt = 0
function love.update(...)
wait(1)
print("asd")
end
function wait(i)
dt = dt + 1
if dt >= love.timer.getFPS() * i then
-- what do i do from here?
end
end
I feel like this is a good start; however, I don't know if it's possible to pause the code in order to wait on a function. How would I do this? Thanks in advance.
function love.load()
wait = 0
end
-- You update has a dt parameter
function love.update(dt)
wait = wait + dt
if wait >= 1 then
wait = wait - 1
print('asd')
end
end
Like Sphyrth said that's the way to do it. Note that there is no guarantee that this will run EXACTLY every second because dt varies a little bit between frames. That's why I recommend using a "fixed" timestep.
Thank you sphyrth, I am aware of how that's one way to do it. I was wondering if there was a way to make a wait() function that pauses the update function. Is this even possible in Love2D?
And chances are high that you do not want to sleep the main thread.
Me and my stuff True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.