[XP] Throwing an Error message

Started by bigace, January 13, 2013, 07:43:59 pm

Previous topic - Next topic

bigace

January 13, 2013, 07:43:59 pm Last Edit: January 13, 2013, 09:36:01 pm by bigace
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.


Use Dropbox to upload your files. Much simpler than other upload sites, you can simply place a folder on your desktop that will sync with your DropBox account.

ThallionDarkshine

Im not quite sure what the problem is with your code, but i think it would work without the first argument.

LiTTleDRAgo

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.")


bigace

I know that, but that doesn't anwser my question. Why does it close without giving a message when you have SystemError in there?


Use Dropbox to upload your files. Much simpler than other upload sites, you can simply place a folder on your desktop that will sync with your DropBox account.

ThallionDarkshine

Maybe some types of errors simply force a quit and log the error somewhere.

bigace

I guess no one knows the answer, if not then I guess we're stuck with ThallionDarkshine answer until then. :(


Use Dropbox to upload your files. Much simpler than other upload sites, you can simply place a folder on your desktop that will sync with your DropBox account.

ThallionDarkshine

Ill look it up, but its probably something like my idea

G_G

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

bigace

Was my game supposed to freeze? As that's what happened when I placed it in my game.


Use Dropbox to upload your files. Much simpler than other upload sites, you can simply place a folder on your desktop that will sync with your DropBox account.

G_G

January 15, 2013, 11:01:19 pm #9 Last Edit: January 15, 2013, 11:06:14 pm by gameus
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"
"

bigace

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.


Use Dropbox to upload your files. Much simpler than other upload sites, you can simply place a folder on your desktop that will sync with your DropBox account.