generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Imperfections with Wait()

Previous Thread :: Next Thread 
TheCrookMeister is not online. TheCrookMeister
Joined: 19 Aug 2009
Total Posts: 517
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
TheCrookMeister is not online. TheCrookMeister
Joined: 19 Aug 2009
Total Posts: 517
03 Apr 2015 11:25 AM
bump
Report Abuse
CrescentJade is not online. CrescentJade
Joined: 07 Jul 2010
Total Posts: 5494
03 Apr 2015 11:26 AM
delay ?
Report Abuse
eLunate is not online. 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
TheCrookMeister is not online. TheCrookMeister
Joined: 19 Aug 2009
Total Posts: 517
03 Apr 2015 11:48 AM
@eLunate, that's not a bad idea, thanks! I'll see what happens
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image