|
| 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 |
|
|
| 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 |
|
|
| 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 |
|