Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

How do I tell which of my scripts is hanging? [Can we say... RESOLVED!!!]

Good day everybody!

I'm having a problem, I haven't worked on my test bed in about a week, and the last time I worked on it everything worked just fine. But, tonight when I went to work on it, I hadn't even started anything yet I just opened up the game to do a quick testplay and test for errors. Right off the bat, I'm at Scene_Title and I selected New Game and got an error "Script is Hanging", and it closed... interesting, very useless error message as it doesn't point to any particular line or anything. I had no previous memory of ever having this error, so I thought I might ask...

I know there is things like Zeriabs No Hangup script, but I'm not interested in "No Hangup", I'm interested in which line or at least which script is causing the problem. I know, obviously its gotta be something either with Scene_Title or Scene_Map, but... keep in mind people, I've got a good 65 scripts I've written along with Aleworks Library and SDK 2.4 on my project, so there is ALOT to search through.

Is there anybody who knows how I can easily find which of these hundreds of scripts is causing the error? Is there a special script out there just for things like this? Or, is there a certain place in the errors module that I can write a method to rescue this hangup and have it point me in the direction of what has triggered it?

EDIT: Since SDK covers all of the default Scenes, that is I think the last thing I did before I had this error was delete all the default RGSS scenes since I'm using nothing but SDK::Scene_Base scenes. With a quick CTRL+ALT+F I see that every Scene_ in my game < SDK::Scene_Base so I doubt thats the problem.

Okay, I've resolved the problem, but reguardless for future reference I'm going to keep this topic open and rephrase it...

Lets say we get a "Script is Hanging" error, but we don't know which script it is, and like me your library is outstandingly humongous... is there an easy workaround to finding which script is causing your hangup?
 

Zeriab

Sponsor

I would add an rescue clause to the begin block in Main like this:
Code:
rescue Hangup => err
  print err.class.to_s + ": " + err.message + "\n\n" + err.backtrace.join("\n")

If you have not modified the Main section the result would be:
Code:
#==============================================================================
# ** Main
#------------------------------------------------------------------------------
#  After defining each class, actual processing begins here.
#==============================================================================

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 Hangup => err
  print err.class.to_s + ": " + err.message + "\n\n" + err.backtrace.join("\n")
end

*hugs*
- Zeriab
 
Oh wow, it returned kn_scene_battle_main_window, that is awesome! I got another hangup when I was trying to make a battle script and thought that the Steal script might've caused it (my newest WIP), I had no idea it was in Scene_Battle main_window!

The whole problem (for anybody reading this) was I had changed...

kn_scene_battle_main to kn_scene_battle_main_window

Then, I called the alias in 'main' (not 'main_window') this is what caused the hangup! I would've probably searched for hours for that one little problem and never have found it if it weren't for you Zeriab! :thumb:

This topic is now Resolved! *Mucho hugs to Zeriab!*
 

Zeriab

Sponsor

I am glad I were of help ^^

Note that if you replace Hangup with Exception you get for all exceptions.
I personally find this can be very annoying, but it can also be nice at times.

*hugs*
- Zeriab
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top