Jump to content


Exerro's Content

There have been 2 items by Exerro (Search limited from 29-March 23)


By content type

See this member's

Sort by                Order  

#279216 Return/break commands not working? [1.12.2]

Posted by Exerro on 04 November 2019 - 08:58 PM in Ask a Pro

View PostLuca_S, on 02 November 2019 - 08:09 PM, said:

Quote

As the return needs to be the last statement in a block Lua is going to interpret
  return
  print(stuck)
end
As returning the return value of print(stuck), which means print(stuck) is executed again.
Other than that I see no reason why the return shouldn't work, please post your whole code.

Yeah, essentially you're doing return print(stuck) as you might do return 5 or something. The return statement will return from the function though so you must be calling fwd in a loop somewhere.



#278732 Can't end program using error() function in parallel? What alternative ca...

Posted by Exerro on 14 January 2019 - 04:16 PM in Ask a Pro

I don't know what's going on here. If "Chat exited" is being printed, and "111" isn't, then you know that the `error()` call is ending the coroutine. From the source of parallel.waitForAny (notably line 30), if a coroutine errors, the error should propagate, so the fact that you're seeing "ok" is very weird.

I've tested a modified version of your code on ccemux:
Spoiler

Maybe upload the full code to pastebin? Also, what version of CC are you using, as there may be differences in the parallel API...?

It's also worth noting that error() generally isn't used to end programs, and a conditional loop like what Luca_S suggested is usually better. Doesn't matter too much though. Whatever works.