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 » Game Design
Home Search
 

Re: A wait function that isn't throttled! :D

Previous Thread :: Next Thread 
RyanDolan123 is not online. RyanDolan123
Joined: 05 Mar 2009
Total Posts: 17919
10 Jul 2013 08:55 PM
If many scripts are all calling wait at once, their behavior is throttled. Why? I don't know.

In Kill The Clones 5.5, with the introduction of rooms, this means the game can sometimes run hoooooooooribly slow.

The solution? A simple "lagless" wait function I came up with. Here it is:
function wait(waittime)
local waittime = waittime
if waittime == nil then
waittime = 0.03
elseif waittime < 0 then
waittime = 0.03
end
local starttime = tick()
repeat
game:GetService("RunService").Stepped:wait()
until tick() >= starttime+waittime
end

(Just put the tabs where they need to go since they won't post on the forum)

It works EXACTLY like the normal wait function, all you have to do is put it before all your other code that uses the wait function.


It uses RunService.Stepped, which means it is called MUCH more often, and it isn't throttled.

This means this wait function is also more accurate as well. The best part about this special function is that it is never throttled. As long as the server isn't extremely overloaded, it will run perfectly fine.


This new function I have rolled out to all the major server-sided scripts in Kill The Clones 5.5.2, and it's making a big difference.

Also I need to roll it out to the clone ais as well...

~wow~
Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
11 Jul 2013 02:16 AM
Why bother when you can just optimise your code, such as controlling all AIs through one script?
Report Abuse
RyanDolan123 is not online. RyanDolan123
Joined: 05 Mar 2009
Total Posts: 17919
11 Jul 2013 07:52 AM
@Notunknown I actually tried that and all it did was slow the game down

The wait function is throttled unlike RunService.Stepped, which also my function is much more precise than the wait function under almost any circumstances.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Game Design
   
 
   
  • 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