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

Forcing a program to exit

Started by Pharap, 30 September 2012 - 01:50 AM
Pharap #1
Posted 30 September 2012 - 03:50 AM
I've almost finished making another game in lua, and all of it works apart from the exiting bit (mainly due to nested loops), so I was wondering if anyone knew of a way to force a program to exit or break out of all loops instead of just the closest one.
I've tried using a repeat until that relies on a boolean value, but since it only tests the value when it reaches the end of the loop, it's not doing what I need at the right time.

It's fine if there isn't a way, I will just have to rearrange the structure, but it would be most handy to know if it does exist. I remember way back when in VB, there was application.exit(), and in XNA there is the ever-popular this.exit(), but as far as I am aware, this feature does not exist in Lua.
Fatal_Exception #2
Posted 30 September 2012 - 03:55 AM
error()
Pharap #3
Posted 30 September 2012 - 04:06 AM
error()

Crude, yet effective.
Lua is a strange language.
I thank you regardless.
Cloudy #4
Posted 30 September 2012 - 10:24 AM
Yeah - generally I just arrange my program's so I can exit them at any point. You can return from functions inside a loop too, or break out of them.

But error() works.