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: Make your wait() more accurate!

Previous Thread :: Next Thread 
XiJennyX is not online. XiJennyX
Joined: 29 Oct 2011
Total Posts: 320
18 Sep 2012 11:35 AM
Use this line of code for the wait to compensate against lag! :D
(Warning, you must wait the wait time for the line of code to work.)

WaitTime = WaitTime - ((wait(WaitTime)-WaitTime))


wait(WaitTime)
Report Abuse
TheCapacitor is not online. TheCapacitor
Joined: 19 Jan 2011
Total Posts: 7045
18 Sep 2012 11:37 AM
"(Warning, you must wait the wait time for the line of code to work.)"

WaitTime = WaitTime / 2, amirite?
Report Abuse
XiJennyX is not online. XiJennyX
Joined: 29 Oct 2011
Total Posts: 320
18 Sep 2012 11:44 AM
No,

I mean that for your new wait time to appear, you need to wait the waittime for it to be processed. My formula is perfect.
Report Abuse
blobbyblob is not online. blobbyblob
Joined: 29 Oct 2008
Total Posts: 12165
18 Sep 2012 11:51 AM
Hah!

Bud, you have to know how wait works. Every frame, it checks to see if the time is greater than value of wait's argument plus whenever the wait function was called. You can't fix the small inaccuracies because you can't return the wait midway through a frame rendering/computing.

Plus, your code makes you wait twice as long, so there's that.
Report Abuse
XiJennyX is not online. XiJennyX
Joined: 29 Oct 2011
Total Posts: 320
18 Sep 2012 12:16 PM
Put
WaitTime = WaitTime - ((wait(WaitTime)-WaitTime))
at the beginning of a script.

Put
wait(WaitTime)
when you want it to wait.

WaitTime - ((wait(WaitTime)-WaitTime))
WaitTime - ((The Actual WaitTime) - WaitTime)

We assume that wait(WaitTime) is larger then the value WaitTime.
So we deduct offset time which is wasted from the initial time to make it accurate.

This is useful for waits inside:
Gun Rate of Fires,
Smooth running actions which require waits lesser then wait(0.01) to occur in a loop.
Report Abuse
XiJennyX is not online. XiJennyX
Joined: 29 Oct 2011
Total Posts: 320
18 Sep 2012 12:22 PM
I discovered this when trying to make my own gun,
I set RPM to 700,
then used a formula to convert it.
RateOfFire = 1/(RPM/60)

But when I compared
print(wait(RateOfFire))
with
print(RateOfFire)

They returned different numbers.

So you deduct the different and wait that new number to get an accurate one.
Report Abuse
XiJennyX is not online. XiJennyX
Joined: 29 Oct 2011
Total Posts: 320
18 Sep 2012 12:23 PM
In big waits such as wait(0.5) you won't need it,
But i'm saying for decimals such as
wait(0.085)
Report Abuse
zars15 is not online. zars15
Joined: 10 Nov 2008
Total Posts: 9999
18 Sep 2012 12:25 PM
Say wut?..

WaitTime = WaitTime - ((wait(WaitTime)-WaitTime))

That just errors.. Great job.
Report Abuse
XiJennyX is not online. XiJennyX
Joined: 29 Oct 2011
Total Posts: 320
18 Sep 2012 12:55 PM
It isn't errors. It works.
Report Abuse
trappingnoobs is not online. trappingnoobs
Joined: 05 Oct 2008
Total Posts: 19100
18 Sep 2012 01:33 PM
or you could just do wait() that is not fluctuating and waits the minimal amount of time possible

or even better you could specify a realistic argument like wait(0.033) so that it waits the same amount of time on every run rather than an arbitrary time which could be an hour if the server takes that long to execute the first wait (Highly unlikely but just to point out a flaw)
Report Abuse
mew903 is not online. mew903
Joined: 03 Aug 2008
Total Posts: 22071
18 Sep 2012 02:09 PM
function wait(time)
local runs = Game:GetService("RunService");
local stepped_t = 0;
local s_tbl = {runs.Stepped:wait()};
if time < s_tbl[2] then
time = s_tbl[2];
end;
for i = 0, time, s_tbl[2] do
stepped_t = stepped_t + s_tbl[2];
if math.floor(stepped_t) == time then
stepped_t = math.floor(stepped_t);
break;
elseif math.ceil(stepped_t) == time then
stepped_t = math.ceil(stepped_t);
break;
end;
end;
for i = 1, stepped_t do
runs.Stepped:wait();
end;
return stepped_t;
end;



psuedo code for my idea idk, probably won't work
this is for rbx.lua obviously, in real lua it's probably something like

function wait(t)
local old = os.time();
repeat until os.time() - old == t;
end;
Report Abuse
jobro13 is not online. jobro13
Joined: 05 Aug 2009
Total Posts: 2865
18 Sep 2012 02:18 PM
You can also process the things in blocks of for example 8/s.

Meaning, 8 ammo per frame for example, interpolating their positions.
Report Abuse
Oysi is not online. Oysi
Joined: 06 Jul 2009
Total Posts: 9058
18 Sep 2012 03:13 PM
[ Content Deleted ]
Report Abuse
TheMyrco is not online. TheMyrco
Joined: 13 Aug 2011
Total Posts: 15105
18 Sep 2012 03:14 PM
wait(0)

Problem fixed.
Report Abuse
Garnished is not online. Garnished
Joined: 09 Apr 2012
Total Posts: 12695
18 Sep 2012 04:08 PM
What the......




Can't even read, it's technically impossible to comprehend this because of the rare chance of a person like "her" can even script, or obviously she is copying off of a wasteful script.

So, you just lost a cookie, so now you have -2 cookies. Tough luck.
Report Abuse
NB3 is not online. NB3
Joined: 27 Dec 2009
Total Posts: 537
18 Sep 2012 04:09 PM
It's nearly impossible to wait, WAITS.
Report Abuse
XiJennyX is not online. XiJennyX
Joined: 29 Oct 2011
Total Posts: 320
19 Sep 2012 07:28 AM
No, you don't get it, none of you.

WaitTime = 0.085 -- This is the time that you want to wait.

print(WaitTime) --> 0.085 -- This is the time that you want to wait.
print(wait(WaitTime)) --> 0.105 -- This is how much you are actually waiting.

We take this difference between them,

(wait(WaitTime) - WaitTime) --> 0.2

And then we deduct that from the WaitTime number.

WaitTime = 0.085 - 0.2 -- This is what actually happens
WaitTime = WaitTime - (wait(WaitTime) - WaitTime) -- This is the formula.

So the new WaitTime is 0.065

So when we check the wait(WaitTime) it will print a number more accurate to the initial WaitTime.

print(WaitTime) --> 0.065
print(wait(WaitTime)) --> ~0.085

WaitTime = WaitTime - (wait(WaitTime)-WaitTime) -- This is the formula.

I've worked hard on helping all of you understand this, and I hope that you use it to help wait be more accurate.

Note to Oysi: Your Algebra is bad because you didn't take BIDMAS into consideration.
BIDMAS is
Brackets,
Indices,
Division,
Multiplication,
Addition,
Subtraction, in respective order.
Report Abuse
trappingnoobs is not online. trappingnoobs
Joined: 05 Oct 2008
Total Posts: 19100
19 Sep 2012 09:47 AM
your logic sucks

why would we want to wait less than the time?
Report Abuse
SN0X is not online. SN0X
Joined: 24 Oct 2011
Total Posts: 7277
19 Sep 2012 10:38 AM
This fails.

Lrnhww8wrksb4 -- Learn how wait works before. Before you do this. Before you mess up half a dozen begginer's games.
Report Abuse
Luc599345 is not online. Luc599345
Joined: 25 Jul 2008
Total Posts: 1169
19 Sep 2012 04:28 PM
@Jenny

>Note to Oysi: Your Algebra is bad because you didn't take BIDMAS into consideration.

You really don't know how to simplify algebraic expressions, do you?

What he said is right. Here's the explanation, here you have this :

WaitTime = WaitTime - ((wait(WaitTime)-WaitTime))
aka
x = x - (f(x)-x)
To simplify what's inside a parenthesis with the 'outside', we distribute the '-' from behind the parenthesis to the inside of the parenthesis.

x = x - f(x) - -x

Two -'s gives us a +, so...

x = x - f(x) + x

Simplifying easily now...

x = 2x - f(x)
aka

WaitTime = 2*WaitTime - wait(WaitTime)
Report Abuse
Luc599345 is not online. Luc599345
Joined: 25 Jul 2008
Total Posts: 1169
19 Sep 2012 04:32 PM
Second note : your so-called 'method' to make it more accurate is bad.
That's not how wait works.
Report Abuse
Sunstaff is not online. Sunstaff
Joined: 25 Sep 2010
Total Posts: 423
19 Sep 2012 05:30 PM
Accurate and Laggy don't have the same meaning.
Report Abuse
sirsavary is not online. sirsavary
Joined: 27 May 2008
Total Posts: 1222
19 Sep 2012 06:22 PM
Alright, so, from what I can tell, we want to make wait() more accurate because sometimes the server has t make adjustments to the amount of time waited?

If so, shouldn't the following work (in the example of X actions per second)

RPM = 60 --60 rounds per minutes, one per second
timeWaited = wait(1)
firedRounds = (timeWaited * RPM) / 2

I don't get why this thread is so complicated.
Report Abuse
Luc599345 is not online. Luc599345
Joined: 25 Jul 2008
Total Posts: 1169
19 Sep 2012 07:33 PM
@Sir

Because the OP keeps insisting her method works and is efficient.
Report Abuse
XiJennyX is not online. XiJennyX
Joined: 29 Oct 2011
Total Posts: 320
20 Sep 2012 09:47 AM
-facepalm-

Roblox's wait() is inaccurate, and sometimes adds a random amount to small wait times such as 0.085.

It turns 0.085 into approximately 0.105, so if you fire 30 bullets with that wait time, you would increase half a second, making it inaccurate when it comes to how much you initially wanted.

So what this script does is calculates how much time is added due to inaccuracy, and deducts it from the initial wait time, making it accurate once again.

So we turn 0.085 into something like 0.065, so that when the 0.02 is added, it comes the exact time which you asked for.
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