|
| 01 Jun 2014 05:09 PM |
Okay, so apparently people misunderstood my question -_-
When I said "How do you make a script wait for exactly 1 second" I meant EXACTLY 1 second.
The wait(1) doesn't wait 1 second, it waits in a range from 0.99900000001 seconds to 1.00000157 seconds.
So, this makes lots of script's timing horrible. You might have noticed that in some games with a timer, sometimes the timer counts slightly faster than its supposed to, sometimes it counts slightly slower than its supposed to.
This is the reason why in Don't Blink, the players sometimes have the informational gui stuck on their screen when they are supposed to try to hide as an angel. |
|
|
| Report Abuse |
|
|
|
| 01 Jun 2014 05:11 PM |
local t = tick () wait (t-tick()+1)
Idk, it actually depends on server speed, its roblox bro.. |
|
|
| Report Abuse |
|
|
|
| 01 Jun 2014 05:11 PM |
| So the question: How do you make the script wait for exactly 1 second? |
|
|
| Report Abuse |
|
|
|
| 01 Jun 2014 05:11 PM |
You can't make it wait exactly 1 second, its just not possible with Roblox. And being .000001 seconds behind isn't a big deal. You'd need to run the wait() function one million times for it to be 1 second off, which would take almost 12 days.
-[::ƧѡÎḾḠΰῩ::]-[::Helper of Scripting and Writer of Wikis::] |
|
|
| Report Abuse |
|
|
|
| 01 Jun 2014 05:12 PM |
Wow, Perfectionist
"Omg honey, I burn't your casserole, I set it to 50.01 Degrees not 50 Degrees" |
|
|
| Report Abuse |
|
|
|
| 01 Jun 2014 05:12 PM |
| Its not judged by server speed, its because the script itself takes time to log the number, sometimes it makes small errors. |
|
|
| Report Abuse |
|
|
|
| 01 Jun 2014 05:12 PM |
*wait(1)* not wait()
-[::ƧѡÎḾḠΰῩ::]-[::Helper of Scripting and Writer of Wikis::] |
|
|
| Report Abuse |
|
|
|
| 01 Jun 2014 05:14 PM |
Also, it doesn't make the timing of anything horrible because, as I said, you'd need to run wait(1) one million times before you even got one second off.
-[::ƧѡÎḾḠΰῩ::]-[::Helper of Scripting and Writer of Wikis::] |
|
|
| Report Abuse |
|
|
|
| 01 Jun 2014 05:20 PM |
| Dude, I did do wait(1). Its just that scripts make small errors here and there, and wait() functions are one of the verbs affected by it. |
|
|
| Report Abuse |
|
|
|
| 01 Jun 2014 05:22 PM |
Oh yeah, and nothing in scripting is accurate. You can do math.random(1, 3). Sometimes it will do 0.99999999999 or 3.00000000000001. It never is accurate, and the script still logs these two values as greater than 1, less than 3.
This is what I learned after studying how my game worked very, very carefully. |
|
|
| Report Abuse |
|
|
|
| 01 Jun 2014 05:22 PM |
" Its just that scripts make small errors here and there"
Use
repeat wait() until -- until it finds its object
code |
|
|
| Report Abuse |
|
|
|
| 01 Jun 2014 05:23 PM |
The wait() function is basically your only option.
-[::ƧѡÎḾḠΰῩ::]-[::Helper of Scripting and Writer of Wikis::] |
|
|
| Report Abuse |
|
|
|
| 01 Jun 2014 05:23 PM |
Time = 1 t = tick() wait (Time) print (t-tick())
Tell me the output, theres less difference than the human mind can even tell |
|
|
| Report Abuse |
|
|
|
| 01 Jun 2014 05:23 PM |
Oh yeah, and nothing in scripting is accurate. You can do math.random(1, 3). Sometimes it will do 0.99999999999 or 3.00000000000001. It never is accurate, and the script still logs these two values as greater than 1, less than 3.
This is what I learned after studying how my game worked very, very carefully. Of course, I may be wrong about the math.random() statement, but the wait() isn't caused by lag, nor is it caused by too many wait() functions, its caused by a phenomenon that occurs often in scripting. |
|
|
| Report Abuse |
|
|
|
| 01 Jun 2014 05:25 PM |
Check the wiki on wait () itll wait close enough to that time, depending on the client/server itself |
|
|
| Report Abuse |
|
|
|
| 01 Jun 2014 05:25 PM |
@silver
That's not true. When given integers as an input the random function can't return a double, it has to be an integer.
-[::ƧѡÎḾḠΰῩ::]-[::Helper of Scripting and Writer of Wikis::] |
|
|
| Report Abuse |
|
|
|
| 01 Jun 2014 05:28 PM |
@swimguy
I said I might be wrong about the math.random part.
@Islandmaker
It outputted 1.016659736633 |
|
|
| Report Abuse |
|
|
|
| 01 Jun 2014 05:33 PM |
It's impossible to wait exactly 1 second. Impossible. The closest we can get is counting 9,192,631,770 oscillations of the cesium 133 atom, which takes about 1,400,000 million years to be off by 1 second.
That's as accurate as we can possibly get and it's STILL not 100% accurate. So deal with the fact that wait(1) is one 1 millionth of a second off.
-[::ƧѡÎḾḠΰῩ::]-[::Helper of Scripting and Writer of Wikis::] |
|
|
| Report Abuse |
|
|
| |
|
ayub32
|
  |
| Joined: 27 Dec 2009 |
| Total Posts: 485 |
|
|
| 01 Jun 2014 05:45 PM |
| Just being curious, do you have OCD? |
|
|
| Report Abuse |
|
|
|
| 01 Jun 2014 11:25 PM |
| yeah, because people totally notice 1/1000th of a second extra/less |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 01 Jun 2014 11:28 PM |
Why do people expect computers to be infinitely perfect? Get over it, many people already complained on this forum "why doesn't wait give me perfect time" |
|
|
| Report Abuse |
|
|
|
| 01 Jun 2014 11:31 PM |
wait(t)
Yields the current thread until t seconds have elapsed. If t is not specified, then it yields for a very short period of time (usually close to 1/30th of a second). The function returns 2 values: The elapsed time and the current place time.
print(Wait(1))
1.004991560393 566.78806415454
|
|
|
| Report Abuse |
|
|
|
| 01 Jun 2014 11:33 PM |
lastTime = tick();
while true do wait() now = tick() if now - lastTime <= 1000 then --do something lastTime = now end end
Want to learn Java? Contact me or visit http://www.roblox.com/Groups/group.aspx?gid=632774 |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
| |
|