Difference between revisions of "Legacy:Abort"
(created from http://web.archive.org/web/20120629081059/http://www.spheredev.org/wiki/Abort) |
(added navbox) |
||
Line 32: | Line 32: | ||
* [[API:Exit|Exit]]() | * [[API:Exit|Exit]]() | ||
* [[API:RestartGame|RestartGame]]() | * [[API:RestartGame|RestartGame]]() | ||
+ | |||
+ | {{API:Engine/navbox}} |
Latest revision as of 22:27, 1 June 2013
Exits the game, just like Exit(). The big difference is that you can pass a custom error message which shows when you exit the game using this function.
Contents
Usage
- error_message String. The message you would like to show when exiting the game. The message is shown in the Sphere display using the default system font.
Examples
var stopped = 12;
Abort("Stopped the engine, code " + stopped + ".");
Aborts with the message "Stopped the engine, code 12." with Sphere error text containing the file and line number where Abort was called.
Abort("Well, thanks for playing.\n");
Shows the text "Well, thanks for playing" and then exits the engine. Due to the trailing newline character (i.e. '\n'), the extra error text Sphere normally displays is not shown.
Notes
This function is useful for debugging and checking if a value was correct or wrong, or if an exception was found in the engine (like doing something that is not allowed).
Setting the last character to be the newline character '\n' (see second example) will stop Sphere from displaying its own error information. This is an easy way to end the game with a message.
See also
- Exit()
- RestartGame()