|
| 09 Jul 2015 02:30 PM |
wait() -- Approx. 1/30 of a second. game:GetService'RunService'.RenderStepped:wait() -- Approx. 1/60 of a second. coroutine.yield() -- ??
Please fill the blank. |
|
|
| Report Abuse |
|
|
Tynezz
|
  |
| Joined: 28 Apr 2014 |
| Total Posts: 4945 |
|
| |
|
| |
|
|
| 09 Jul 2015 02:37 PM |
coroutine.yield yields until the coroutine is resumed again
here's an example
local thread = coroutine.wrap(function() for i = 1, 4 do print(i) coroutine.yield() end end)
thread() -> 1 thread() -> 2 thread() -> 3 thread() -> 4 thread() -> 'cannot resume dead coroutine'
but coroutine.yield() also supports changing arguments, for example:
local thread = coroutine.wrap(function(argument) for i = 1, 4 do print(argument) argument = coroutine.yield() end end)
thread("hi") -> "hi" thread("bye") -> "bye" thread("boo") -> "boo" thread("poop") -> "poop" thread("rip") -> 'cannot resume dead coroutine' |
|
|
| Report Abuse |
|
|
gskw
|
  |
| Joined: 05 Jan 2013 |
| Total Posts: 1364 |
|
|
| 09 Jul 2015 02:38 PM |
It varies a lot. I think it waits for the next task scheduler tick.
This is a signature. Recommended username: NosyGskw |
|
|
| Report Abuse |
|
|
|
| 09 Jul 2015 02:41 PM |
local wew = true; local i = 0
spawn(function() repeat coroutine.yield() i = i + 1 until wew == false end)
wait(1.1) wew = false print(i) --> 35000
local wew = true; local i = 0
spawn(function() repeat wait() i = i + 1 until wew == false end)
wait(1.1) wew = false print(i) --> 28
|
|
|
| Report Abuse |
|
|
| |
|