|
| 03 Apr 2015 11:10 AM |
The function wait(t) returns the actual time it paused your script based on the argument t. It never quite pauses for that exact amount of time, though; it's usually just a bit longer. That can be a problem if you're like me and have a setup like this:
-------------------------------------------------------------- local speed = 1 -- number of seconds local frames = 20 -- number of times the loop will loop local actualSpeed local count = 0
for i = count, 1, 1/frames do count = i -- 0, 0.05, 0.1, 0.15, ... 1 actualSpeed = wait(speed/frames) -- actualSpeed should equal 0.05. (speed/frames) * frames = 0.05 * 20 = 1 end --------------------------------------------------------------
Hopefully you can see that if wait() were perfect, the loop would take exactly 1 second to complete.
Since that's not the case, though, I'm wondering if anybody knows how to make this loop time out more accurately? |
|
|
| Report Abuse |
|
|
| |
|
| |
|
eLunate
|
  |
| Joined: 29 Jul 2014 |
| Total Posts: 13268 |
|
|
| 03 Apr 2015 11:27 AM |
local I = 0; while I < UPPERLIMITSECONDS do I = I + wait(0) end
That's the best you're getting without doing wait(1-lastDiff) |
|
|
| Report Abuse |
|
|
|
| 03 Apr 2015 11:48 AM |
| @eLunate, that's not a bad idea, thanks! I'll see what happens |
|
|
| Report Abuse |
|
|