Jump to content




Forcing a program to exit

lua

  • You cannot reply to this topic
3 replies to this topic

#1 Pharap

  • Members
  • 816 posts
  • LocationEngland

Posted 30 September 2012 - 02: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.

#2 Fatal_Exception

  • New Members
  • 105 posts

Posted 30 September 2012 - 02:55 AM

error()

#3 Pharap

  • Members
  • 816 posts
  • LocationEngland

Posted 30 September 2012 - 03:06 AM

 Fatal_Exception, on 30 September 2012 - 02:55 AM, said:

error()

Crude, yet effective.
Lua is a strange language.
I thank you regardless.

#4 Cloudy

    Ex-Developer

  • Members
  • 2,543 posts

Posted 30 September 2012 - 09: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.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users