j1my3p1x
|
  |
| Joined: 16 Jan 2010 |
| Total Posts: 978 |
|
|
| 17 Aug 2014 09:13 AM |
I'm doing something for debugging and I need a coroutine to break the script, not just the coroutine thread. How could I do this?
I resume a coroutine that does error() but the coroutine stops, not the rest of the script. |
|
|
| Report Abuse |
|
|
iiEssence
|
  |
| Joined: 18 Jun 2014 |
| Total Posts: 3467 |
|
| |
|
blockoo
|
  |
| Joined: 08 Nov 2007 |
| Total Posts: 17202 |
|
|
| 17 Aug 2014 09:21 AM |
| Wow, I had this exact same question yesterday. There's a really complex way to do it with metatables, but more simply you can just use script.Disabled = true |
|
|
| Report Abuse |
|
|
blockoo
|
  |
| Joined: 08 Nov 2007 |
| Total Posts: 17202 |
|
|
| 17 Aug 2014 09:24 AM |
Or, if that's not satisfying, I think I found another way:
function breakScript() --do some stuff return "error('Script broken')" end
loadstring(coroutine.wrap(breakScript)())() |
|
|
| Report Abuse |
|
|
j1my3p1x
|
  |
| Joined: 16 Jan 2010 |
| Total Posts: 978 |
|
|
| 17 Aug 2014 09:27 AM |
| Oh right, script.Disabled. Gosh I feel stupid. Thanks! |
|
|
| Report Abuse |
|
|
blockoo
|
  |
| Joined: 08 Nov 2007 |
| Total Posts: 17202 |
|
|
| 17 Aug 2014 09:28 AM |
| Actually, using Disabled will allow it to complete a function instead of killing the script exactly when you want it to error. Not sure if this will be a problem for you or not, though. |
|
|
| Report Abuse |
|
|
j1my3p1x
|
  |
| Joined: 16 Jan 2010 |
| Total Posts: 978 |
|
|
| 17 Aug 2014 09:41 AM |
Not really a problem. I just need to pause a script after X amount of seconds to see how accurate my timer thing is and tweak it.
|
|
|
| Report Abuse |
|
|