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

[solved]looking for a way to exit program without an error message

Started by zazarath, 08 June 2013 - 11:53 AM
zazarath #1
Posted 08 June 2013 - 01:53 PM
at i am using error() to get the program to shut down i have tryed os.exit() and exit() but both just have the error attempt to call nill and i looked on the wiki and the lua website (which btw i cant figure out for the life of me) and i cant seen to find what i am looking for.
trying to exit the program from within a loop thats in a loop thats in a loop =P ( i am going loopy)


plz help this is like the last thing i need for my mining program then i got to get the gui sorted then i relising it
BigSHinyToys #2
Posted 08 June 2013 - 02:33 PM
I don't know if this is "good code" but

do return end
http://www.lua.org/m...nual.html#2.4.4

[EDIT]
testing that it doesn't actually seam to work srry
Engineer #3
Posted 08 June 2013 - 03:03 PM
You actually only need return. But, this is only possible in an if-statement or something similair:

something = true
print("hi")
if something then
   return --#Works
end
return -- Wont work
print("hey")
For simplicity, just use error(). You can use that everywhere in your code, and it is not bad to use, at all.

edit: for error(), you do not have to give it contents. Try this out:

print("hi!")
error()
print("Hey!")
Edited on 08 June 2013 - 01:17 PM
zazarath #4
Posted 08 June 2013 - 05:30 PM
thanks, =) after about 1 hour of trying to sort out mobs getting in the way of the turtle its nealry finished woop =) well first reliece anyways just so i can see what plp think of it.