|
| 01 Nov 2017 06:25 PM |
in roblox, for some reason, doing coroutine.yield() on the script's main thread will return the same thing as wait() w/o arguments is there a way to actually yield it? im trying to push it into a table of threads to be resumed later |
|
|
| Report Abuse |
|
|
|
| 01 Nov 2017 06:32 PM |
| forced to use coroutines atm for the main thread |
|
|
| Report Abuse |
|
|
doggy00
|
  |
| Joined: 11 Jan 2011 |
| Total Posts: 3571 |
|
|
| 01 Nov 2017 06:35 PM |
this may help:
https://devforum.roblox.com/t/method-for-yielding-a-script/35221 |
|
|
| Report Abuse |
|
|
EdgyCnt
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44744 |
|
|
| 01 Nov 2017 06:36 PM |
you can't
Roblox's thread scheduler will resume your thread whenever the time passes but it will not remove this thread from its thread queue. This means that calling coroutine.yield sure will yield the thread but when the thread scheduler reaches it it will be resumed instantly since coroutine.yield does not set the "time to resume" field.
Wrap your code in coroutine.create and do not yield from within it, then coroutine.yield will work as expected because the coroutine won't be registered to Roblox's thread sched. |
|
|
| Report Abuse |
|
|
EdgyCnt
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44744 |
|
|
| 01 Nov 2017 06:37 PM |
you can't with coroutine.yield alone* (unless you wrap everything)
|
|
|
| Report Abuse |
|
|
|
| 01 Nov 2017 07:03 PM |
| i did wrap everything and i tried this, my finished script ########################### however, using wait() will make the thread belong to roblox and so will yielding one time i will soon split it away from metas so i can transfer it across scripts on the same machine |
|
|
| Report Abuse |
|
|
|
| 01 Nov 2017 09:18 PM |
ok i found out i can trick it by using wait(1/0) as that makes roblox yield it for eternity i use coroutine.resume(thread) where thread was stored from coroutine.running() it works ok but i cant seem to figure out how i would send the parameters |
|
|
| Report Abuse |
|
|
| |
|
| |
|