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)
0
Help needed
Started by husplante, Oct 12 2014 12:17 PM
6 replies to this topic
#1
Posted 12 October 2014 - 12:17 PM
#2
Posted 12 October 2014 - 01:19 PM
You can use an empty error function like so:
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.)
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.)
#3
Posted 12 October 2014 - 04:42 PM
Ty Jiloacom
#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.
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.
#6
Posted 21 November 2014 - 07:19 PM
Nemisis, on 21 November 2014 - 02:16 PM, said:
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.
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 by Jiloacom, 21 November 2014 - 07:19 PM.
#7
Posted 26 November 2014 - 10:44 AM
Thanx, that helps explain which exit strategy to use.
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users