Help with making a wait() function

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
TypicalHB
Prole
Posts: 8
Joined: Sat Nov 23, 2019 4:20 am

Help with making a wait() function

Post by TypicalHB »

Hello, I'm having issues with this wait() function that I made. It just seems to crash love when I call it. No error. it just opens, and then crashes.

Code: Select all

function wait(seconds)
  local start = os.time()
  repeat until os.time() > start + seconds
end
grump
Party member
Posts: 947
Joined: Sat Jul 22, 2017 7:43 pm

Re: Help with making a wait() function

Post by grump »

That code shouldn't crash. If it crashes then something is wrong with your system. It may result in a "Application is not responding" message from your OS if the value for seconds is sufficiently large, but it shoudn't crash.

Love already has a function for that, btw: love.timer.sleep.
User avatar
zorg
Party member
Posts: 3465
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: Help with making a wait() function

Post by zorg »

Besides, unless you literally want to suspend all processing, you shouldn't use that either; implement a timer or use a library instead like https://hump.readthedocs.io/en/latest/timer.html
Me and my stuff :3True 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.
Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 6 guests