I have just joined, so I do not know if this is in the right area of the Forums. Sorry.
I have played a few other games where they have wait() functions and I was wondering if there was anything like that here.
I am trying to make a character jump when you hit the up arrow but I don't have a wait function, so I can't seem to work it.
Is there such thing as a wait() function?
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: Is there such thing as a wait() function?
A quick search for "lua sleep function" gives (from http://lua-users.org/wiki/SleepFunction):
Note that this is a blocking function, meaning while you're waiting, you cannot do anything else - essentially, you're freezing the game for a while. If you want a non-blocking function, you need to integrate your code with the while loop somehow.
Code: Select all
local clock = os.clock
function sleep(n) -- seconds
local t0 = clock()
while clock() - t0 <= n do end
end
-- warning: clock can eventually wrap around for sufficiently large n
-- (whose value is platform dependent). Even for n == 1, clock() - t0
-- might become negative on the second that clock wraps.
Re: Is there such thing as a wait() function?
Somebody needs to tell the developers to add a wait() function....
Re: Is there such thing as a wait() function?
There was a thread about this just last week: viewtopic.php?f=4&t=9345
- bartbes
- Sex machine
- Posts: 4946
- Joined: Fri Aug 29, 2008 10:35 am
- Location: The Netherlands
- Contact:
Re: Is there such thing as a wait() function?
@litearc: That's absolutely terrible. It's a busy loop, they are bad. At least mention love.timer.sleep.
But, as linked before, you don't want to pause execution.
But, as linked before, you don't want to pause execution.
Who is online
Users browsing this forum: Bing [Bot] and 2 guests