So I was trying to throw an error message if the developer put in an Input:: I deem unusable and then the program closes. The problem is that the program closes with out throwing the error message.
raise(SystemExit, "Sorry, but the button inputs B, L, R, UP, DOWN, RIGHT, " +
"LEFT, F5, 56, F7, F8, or F9 is not allow. " +
"Please choose A, C, X, Y, Z, or SHIFT inputs instead for the scene " +
"changing button.")
I know this code works:
print("Sorry, but the button inputs B, L, R, UP, DOWN, RIGHT, LEFT, F5, " +
"56, F7, F8, or F9 is not allow. " +
"Please choose A, C, X, Y, Z, or SHIFT inputs instead for the scene " +
"changing button.")
exit
But I was wondering why the first code doesn't work. Thats all.
Im not quite sure what the problem is with your code, but i think it would work without the first argument.
Quote from: bigace on January 13, 2013, 07:43:59 pm
Quoteraise(SystemExit, "Sorry, but the button inputs B, L, R, UP, DOWN, RIGHT, " +
"LEFT, F5, 56, F7, F8, or F9 is not allow. " +
"Please choose A, C, X, Y, Z, or SHIFT inputs instead for the scene " +
"changing button.")
I know that, but that doesn't anwser my question. Why does it close without giving a message when you have SystemError in there?
Maybe some types of errors simply force a quit and log the error somewhere.
I guess no one knows the answer, if not then I guess we're stuck with ThallionDarkshine answer until then. :(
Ill look it up, but its probably something like my idea
A SystemExit exception is when the program is closed via system. AKA Closing it through the Red X button. You can usually catch the exception and do some finalizing code. So if you're making the script throw a SystemExit exception, it's just going to close the game without any warning, as if someone were actually closing the game. Replace "Main" with this snippet and close the game with the Red X. You'll see what I'm talking about.
begin
# Prepare for transition
Graphics.freeze
# Make scene object (title screen)
$scene = Scene_Title.new
# Call main method as long as $scene is effective
while $scene != nil
$scene.main
end
# Fade out
Graphics.transition(20)
rescue Errno::ENOENT
# Supplement Errno::ENOENT exception
# If unable to open file, display message and end
filename = $!.message.sub("No such file or directory - ", "")
print("Unable to find file #{filename}.")
rescue SystemExit
print "Closed via X"
end
Was my game supposed to freeze? As that's what happened when I placed it in my game.
When I run the game with that script and close the game with the X button, it prints out "Closed via X" You were supposed to have replaced "Main"
"
I did replace Main :<_<: , but my computer was being retarded so the game froze then crashed. I just tested it again a second ago and it did everything you just said. Thank you for the information.