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

Help needed

Started by husplante, 12 October 2014 - 11:17 AM
husplante #1
Posted 12 October 2014 - 01:17 PM
Hello i was wondering if you could cancel a program as soon as a turtles fuel level is below a certain amount?
like a: turtle.getFuelLevel() if turtle.getFuelLevel() < 100 then (cancel code)
Saldor010 #2
Posted 12 October 2014 - 02:19 PM
You can use an empty error function like so:


error()

All it does is silently terminate the program, just like it would if you held down CTRL-T. (Except for the lack of the Terminated message.)
husplante #3
Posted 12 October 2014 - 05:42 PM
Ty Jiloacom
Saldor010 #4
Posted 12 October 2014 - 09:23 PM
Ty Jiloacom

No problem man. ;)/>
Nemisis #5
Posted 21 November 2014 - 02:16 PM
Just curious. (as a decent answer was given already)
Would something like " If condition exists then exit " work.

I am new to both CC and LUA so am interested in this as part of an error handler routine.
Saldor010 #6
Posted 21 November 2014 - 07:19 PM
Just curious. (as a decent answer was given already)
Would something like " If condition exists then exit " work.

I am new to both CC and LUA so am interested in this as part of an error handler routine.

I believe the only "exit" function that exists, is either return/break (return, which if you're in a function, ends the function; break, which if you're in a loop, ends the loop), or error (already explained).
Edited on 21 November 2014 - 06:19 PM
Nemisis #7
Posted 26 November 2014 - 10:44 AM
Thanx, that helps explain which exit strategy to use.