5/15/12

Using 'WAIT' Wisely

We're sorry!

We haven't been updating The Current Roblox News as much as we used to. This is because of iHtc's problem at the moment. (something to do with his mum & dad)
________________________________________________________________________________

Using 'wait' Wisely

A little cut out of what was posted on ROBLOX Blog:
Many script's want to run bit's of code at frequent intervals. For example, the script might might update the behaviour of a zombie. It need's to update condition's repeatedly, like checking the location of the closest player to the zombie.
ROBLOX is trying to tell you, that instead of using wait(), you can use wait(10) instead.

Because if you just leave the bracket () empty, wait() will be regening 1000 times a second, yet instead, you could just have 10 items regening a second. Games with just wait() tend to be the more laggy ones, making your player's just click [X] in the corner! (or of course your red O)

For example:


while true do
findClosestEnemy()
wait()
end

that, above isn't a good script. Can you spot the mistake?

But, this below, is correct. Can you see why?


while true do
findClosestEnemy()
wait(5.0)
end

Even I know how to do that, and I already did. (and you know how rubbish at scripting I am!) So really, ROBLOX is just giving you a reminder, but it's also a lesson for the people whose zombie game's are laggy!

iHtc