Jump to content




Help needed


6 replies to this topic

#1 husplante

  • Members
  • 7 posts

Posted 12 October 2014 - 12: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)

#2 Saldor010

  • Members
  • 467 posts
  • LocationThe United States

Posted 12 October 2014 - 01: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.)

#3 husplante

  • Members
  • 7 posts

Posted 12 October 2014 - 04:42 PM

Ty Jiloacom

#4 Saldor010

  • Members
  • 467 posts
  • LocationThe United States

Posted 12 October 2014 - 08:23 PM

View Posthusplante, on 12 October 2014 - 04:42 PM, said:

Ty Jiloacom

No problem man. ;)

#5 Nemisis

  • Members
  • 7 posts

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.

#6 Saldor010

  • Members
  • 467 posts
  • LocationThe United States

Posted 21 November 2014 - 07:19 PM

View PostNemisis, 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.

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 Nemisis

  • Members
  • 7 posts

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