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: wait() inaccuracy?

Previous Thread :: Next Thread 
Ozzypig is not online. Ozzypig
Joined: 27 Mar 2008
Total Posts: 4906
10 Jun 2012 01:49 PM
Usually calling wait() in a script will yield the current thread for about .03 seconds, but I'm getting in excess of .2 seconds. Is anyone else getting this?
Report Abuse
popinman322 is not online. popinman322
Joined: 04 Mar 2009
Total Posts: 5184
10 Jun 2012 01:50 PM
Explicit wait(0.03)?
Report Abuse
MM233 is not online. MM233
Joined: 19 Jun 2008
Total Posts: 925
10 Jun 2012 01:56 PM
wait() was changed. I believe it's now got 60 FPS, instead of the previous 30 FPS.
Report Abuse
Ozzypig is not online. Ozzypig
Joined: 27 Mar 2008
Total Posts: 4906
10 Jun 2012 01:57 PM
@mm233 that's probably not it considering it would be .015 not .2

@popin Didn't seem to work. Something must be up with ROBLOX's scheduler thingy
Report Abuse
MrBlockson is not online. MrBlockson
Joined: 31 Aug 2008
Total Posts: 14276
10 Jun 2012 08:18 PM
It's dependant on the framerate and probably slightly more (i.e. any amount of time it takes to actually execute the code).

That's all I can think of.
Report Abuse
NVI is not online. NVI
Joined: 11 Jan 2009
Total Posts: 4744
10 Jun 2012 09:12 PM
wait() yields the current thread. If there's a lot going on in other threads, you're not going to get priority back any time soon. Stop using wait(), you fool.
Report Abuse
LPGhatguy is not online. LPGhatguy
Forum Moderator
Joined: 27 Jun 2008
Total Posts: 4725
10 Jun 2012 09:48 PM
You're getting throttled. Use the return value for delta so you're not affected as much.
Report Abuse
X135 is not online. X135
Joined: 20 Aug 2010
Total Posts: 245
10 Jun 2012 10:03 PM
Yes. It's prone to throttling.

Use wait(1/30)

☜▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬☜☆☞▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬☞ - Candymaniac, a highly reactive substance.
Report Abuse
JulienDethurens is not online. JulienDethurens
Joined: 11 Jun 2009
Total Posts: 11046
10 Jun 2012 10:46 PM
Just use the wait function properly instead.

Don't use wait() and don't use wait(1/30) either. Just use wait properly.
Report Abuse
Oysi is not online. Oysi
Joined: 06 Jul 2009
Total Posts: 9058
11 Jun 2012 04:44 AM
[ Content Deleted ]
Report Abuse
oxcool1 is not online. oxcool1
Joined: 05 Nov 2009
Total Posts: 15444
11 Jun 2012 06:01 AM
[ Content Deleted ]
Report Abuse
SundownMKII is not online. SundownMKII
Joined: 26 Sep 2010
Total Posts: 12880
11 Jun 2012 06:10 AM
wait() does the following:
waits about a frame (approximately in a no-lag situation, actually 1/30th of a second)
fires instantly in a no-lag setting
auto-throttled if there is no value typed as an argument

~>dat siggy<~
Report Abuse
oxcool1 is not online. oxcool1
Joined: 05 Nov 2009
Total Posts: 15444
11 Jun 2012 06:48 AM
[ Content Deleted ]
Report Abuse
oxcool1 is not online. oxcool1
Joined: 05 Nov 2009
Total Posts: 15444
11 Jun 2012 06:49 AM
[ Content Deleted ]
Report Abuse
oxcool1 is not online. oxcool1
Joined: 05 Nov 2009
Total Posts: 15444
11 Jun 2012 06:49 AM
[ Content Deleted ]
Report Abuse
Maelstronomer is not online. Maelstronomer
Joined: 07 Jun 2008
Total Posts: 7649
11 Jun 2012 07:02 AM
I too would like to know more about an alternative to wait(). I've never used the following functions so could I have them explain their usefulness please?

The wiki doesn't mention thread yielding for delay() but it does for spawn(). Tick() is said to be very accurate and seems promising. Game time apparently only updates during wait() and that would make time() not so useful.
Report Abuse
Knexer is not online. Knexer
Joined: 03 May 2009
Total Posts: 13851
11 Jun 2012 07:04 AM
nuh-uh
Report Abuse
Friaza is online. Friaza
Joined: 26 Dec 2008
Total Posts: 6229
11 Jun 2012 03:54 PM
Either way, my game uses wait() and wait(0.05) thousands of times, I really need to fix this, it's ruining my game...
Report Abuse
JulienDethurens is not online. JulienDethurens
Joined: 11 Jun 2009
Total Posts: 11046
11 Jun 2012 06:20 PM
"So you just come here saying everyone on roblox uses the wait function incorrectly, even the admins and their built in code. And then you don't bother saying how to "actually use it properly." Yeah, because people won't look at you like an idiot now..."

When did I say nobody was using it correctly?

If you use 'wait()', you're accepting the fact that it will wait one frame and that the duration of a frame may vary. You can't expect 'wait()' to wait exactly 1/30 of a second or even a value close to that. If you want to wait 1/30 of a second, you have to use 'wait(1/30)'.

However, why would you wait 1/30 of a second in the first place? Because it's the default time a frame takes, or took? That's not a good reason. Wait the time you want to wait, instead.

"wait() does the following:
waits about a frame (approximately in a no-lag situation, actually 1/30th of a second)
fires instantly in a no-lag setting
auto-throttled if there is no value typed as an argument"

Why does nobody actually understand how the wait function work except me and a few other scripters?

This is how the wait function works: wait() does the following:
waits about a frame (approximately in a no-lag situation, actually 1/30th of a second)
fires instantly in a no-lag setting
auto-throttled if there is no value typed as an argument.

"I too would like to know more about an alternative to wait()."

The wait function has no alternative and shouldn't have an alternative. The point of it is to wait a certain time. Why would you need an alternative?

The point when programming isn't to have 5000 ways to do something, it is to have ONE _GOOD_ way to do it.

@oxcool

If you want to test stuff, use the preview button. Or, at least, create a thread in the OT forum and lock it.
Report Abuse
catslats1 is not online. catslats1
Joined: 02 Nov 2009
Total Posts: 138
11 Jun 2012 09:30 PM
Yup needs to fix wait
Report Abuse
stravant is not online. stravant
Forum Moderator
Joined: 22 Oct 2007
Total Posts: 2893
11 Jun 2012 10:18 PM
As for what you are seeing, along with the 60FPS update, scripts are more aggressively throttled, so if your game is doing too much script stuff rather than just cutting out scripts entirely or slowing down other engine activities it will increase the wait time one scripts.

So, you cannot assume that your code will actually wait for the requested time anymore.
Report Abuse
NinjaShadow1 is not online. NinjaShadow1
Joined: 03 Mar 2009
Total Posts: 2689
11 Jun 2012 11:06 PM
I'd rather have 30 fps and it be reliable than 60 and unreliable.
Report Abuse
JulienDethurens is not online. JulienDethurens
Joined: 11 Jun 2009
Total Posts: 11046
11 Jun 2012 11:08 PM
@NinjaShadow

Why not just use it correctly and not have any problem?
Report Abuse
stravant is not online. stravant
Forum Moderator
Joined: 22 Oct 2007
Total Posts: 2893
11 Jun 2012 11:33 PM
"I'd rather have 30 fps and it be reliable than 60 and unreliable."

If you weren't having other problems before then you won't have problems with it now. You have to be doing pretty aggressive operations to actually trigger it. Plus, it's better than before where it would just ungracefully fail. Being slightly harder to work with (Really, it's not much code at all to add a time-step to something once you know how, just local dt = wait(), youramount*speed*dt)
Report Abuse
Oysi is not online. Oysi
Joined: 06 Jul 2009
Total Posts: 9058
12 Jun 2012 04:54 AM
[ Content Deleted ]
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