|
| 11 Jul 2015 12:04 PM |
So, Heres a coroutine I made
local swing = coroutine.wrap(function(n) local nothing = 0 while true do connect["Right Arm->Torso"].C1 = connect["Right Arm->Swing"] wait(.5) connect["Right Arm->Torso"].C1 = connect["Right Arm->Torso->Internal"] print("Done") nothing = coroutine.yield() end end)
(connect[]'s are just for my welding stuff)
It keeps printing "Done" every .5 seconds |
|
|
| Report Abuse |
|
|
|
| 11 Jul 2015 12:12 PM |
| You need "break", not coroutine.yield. |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 11 Jul 2015 12:18 PM |
| No, I'm pretty sure he wants to yield it so he can call swing later. |
|
|
| Report Abuse |
|
|
|
| 11 Jul 2015 12:31 PM |
Yeah I wanted to use this as a function, but a function that could be ran while my main code still runs...
Does coroutine.yield() not work for roblox? |
|
|
| Report Abuse |
|
|
|
| 11 Jul 2015 12:37 PM |
I compiled lua in visual studio and coroutine.yield works just fine there.
How do I implement this for roblox?
I want it to wait (be suspended) until the function (coroutine.wrap) is called again |
|
|
| Report Abuse |
|
|
|
| 11 Jul 2015 12:42 PM |
| Again, since you want to yield every loop, either remove the loop, or put a break statement. |
|
|
| Report Abuse |
|
|
|
| 11 Jul 2015 12:43 PM |
You cant, Once a coroutine.wrap ends you cant call swing() again because the coroutine is "dead" and there is no way to restart it.
In wiki it uses coroutine.yield. |
|
|
| Report Abuse |
|
|
|
| 11 Jul 2015 12:45 PM |
| Well then just use spawn() instead of making a coroutine. |
|
|
| Report Abuse |
|
|
|
| 11 Jul 2015 12:50 PM |
| I dont think theres a coroutine.spawn |
|
|
| Report Abuse |
|
|
|
| 11 Jul 2015 01:01 PM |
It's a Roblox-specific function.
spawn(swing) -- "swing" should be a function, not a coroutine. Be warned that you can't send arguments through "spawn". |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 11 Jul 2015 01:02 PM |
OP I think it might have something to do with having a wait function call in there, I tested this and it worked fine on Roblox:
local test = coroutine.wrap(function() while true do print(coroutine.yield()); end end);
test(); test("Hi"); test("Bye"); |
|
|
| Report Abuse |
|
|
|
| 11 Jul 2015 01:15 PM |
I changed it to a coroutine.create and coroutine.yield still doesnt work.
I really need the wait in there though
Is there a way I can delay in a coroutine without wait? |
|
|
| Report Abuse |
|
|