This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
ds84182's profile picture

Is there any way to error the current lua thread within a peripheral?

Started by ds84182, 26 November 2012 - 03:52 AM
ds84182 #1
Posted 26 November 2012 - 04:52 AM
Whenever I use CCLights, I may put a value in wrong. The problem is that I need a way to error the current lua thread. It would be great to use IComputerAccess to error the lua thread, but browsing the code yields no results. It would be a great feature for later use by all peripherals.
Cloudy #2
Posted 26 November 2012 - 06:14 AM
throw new Exception("Oh noes, we has error!");
ds84182 #3
Posted 01 December 2012 - 02:33 PM
throw new Exception("Oh noes, we has error!");
Thanks Cloudy!
bbqroast #4
Posted 02 December 2012 - 04:00 PM
throw new Exception("Oh noes, we has error!");
Wouldn't that error the entire game and crash it? Which would be very bad for a server (having the entire server crash because one user inputed a wrong value into a computer).
You could queue an error event (hopefully the user would see it).
Xfel #5
Posted 02 December 2012 - 09:10 PM
Not if you are within IPeripheral.call(). The lua machine catches the exception and propangates it as lua error.

I you are outside it, (eg in the minecraft update loop), this doesn't work of course, but who would try to launch a lua error from there anyway?
Cloudy #6
Posted 04 December 2012 - 06:54 AM
throw new Exception("Oh noes, we has error!");
Wouldn't that error the entire game and crash it? Which would be very bad for a server (having the entire server crash because one user inputed a wrong value into a computer).
You could queue an error event (hopefully the user would see it).

I wouldn't have suggested it had that been the case.