Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Faster repeat method than while true do?

Asked by 6 years ago

I have programmed a world generator and

while true do 
wait ()

end

already generates too much delay and ensures that the world is generated very slowly

0
You don't need to wait() after every iteration. You can do 10, 20, even 100 at a time without any problems. Just make sure it does eventually wait or it will hang. ee0w 458 — 6y
1
Use a hearbeat wait? xPolarium 1388 — 6y
0
Loading in chunks is definitely the way to go for this. xPolarium 1388 — 6y
0
Absolutely chunks imo if your doing any kind of terrain generator ABK2017 406 — 6y
View all comments (3 more)
0
Unless you mean just the loading, in which case you can look into Network StreamingEnabled but read up on it because it effects a lot in local scripts ABK2017 406 — 6y
0
Take a look at RunService's Events => https://www.robloxdev.com/api-reference/class/RunService. And indeed, the above user''s suggestions are highly recommended. Nevertheless, the answer to your question can be found in RunService's Events; Stepped, Heatbeat or RenderStepped Zafirua 1348 — 6y
0
A "faster" method without a wait will crash the server if it's a infinite loop. angeI1001 123 — 6y

1 answer

Log in to vote
-1
Answered by
LuaDLL 253 Moderation Voter
6 years ago
local amount = 0
local MaxAmount = 20 -- 10,20,100
while true do
if amount+1 > MaxAmount then
amount = 0
wait() -- Set Amount
return
end
amount = amount+1
if amount == MaxAmount then
amount = 0
wait() -- Set amount
return
end

-- Do rest


end
0
Idk if this is what u were looking for but its what i thought u were so LuaDLL 253 — 6y
1
nice explanation ee0w 458 — 6y
0
cool. I once did this accidentally with it going 1000 times before wait () and my frames per second went down to like 1/2 but it didn't hang. Really annoying. OBenjOne 190 — 6y
1
please properly indent your code. User#21908 42 — 6y
Ad

Answer this question