|
| 19 Jan 2017 02:31 AM |
Hey, so I have a coroutine inside a module script, which is used to play a game-mode so that the main script can track the progress of who is alive, etc. Problem is because its a coroutine it won't just end. So how can I make it just stop the coroutine? Thanks :)
|
|
|
| Report Abuse |
|
|
|
| 19 Jan 2017 05:27 AM |
module = {} module.Coro module.Run = function()module.Coro=coroutine.wrap(function() --stuff end)end) module.End = function()coroutine.yield(module.Coro)end) |
|
|
| Report Abuse |
|
|
chimmihc
|
  |
| Joined: 01 Sep 2014 |
| Total Posts: 17143 |
|
|
| 19 Jan 2017 06:55 AM |
"module = {} module.Coro module.Run = function()module.Coro=coroutine.wrap(function() --stuff end)end) module.End = function()coroutine.yield(module.Coro)end)"
Noooo. That won't work.
|
|
|
| Report Abuse |
|
|
|
| 19 Jan 2017 09:35 AM |
| Then why not give a solution? I rarelly use modules myself and would like to know the answer to this question too. |
|
|
| Report Abuse |
|
|
chimmihc
|
  |
| Joined: 01 Sep 2014 |
| Total Posts: 17143 |
|
|
| 19 Jan 2017 10:11 AM |
I would if I knew the problem. All I know is that there is a coroutine in a module, that isn't enough to go off of.
|
|
|
| Report Abuse |
|
|
|
| 19 Jan 2017 10:13 AM |
| He basically wants to yield a coroutine on command which is in the module. |
|
|
| Report Abuse |
|
|
chimmihc
|
  |
| Joined: 01 Sep 2014 |
| Total Posts: 17143 |
|
|
| 19 Jan 2017 10:31 AM |
Still not sure what the problem is, but maybe this will help:
local module = {}
function module:run() self.running = true coroutine.resume(coroutine.create(function() while self.running do -- stuff end end)) end
function module:stop() self.running = false end
return module
|
|
|
| Report Abuse |
|
|