Advertisement
Rafael_Sol_Maker

RAFAEL_SOL_MAKER's VX GENERAL SCRIPT EVALUATOR v1.0a

Nov 17th, 2011
310
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 3.88 KB | None | 0 0
  1. #===============================================================================
  2. #            RAFAEL_SOL_MAKER's VX GENERAL SCRIPT EVALUATOR v1.0a
  3. #          Based on 'Detailled Call Script Error Message' by ERZVX.
  4. #-------------------------------------------------------------------------------
  5. # Description:  Check all scripts generated "by the game", like the "Run Script"
  6. #               event commmand, event move routes, or even event conditions.
  7. #               It will act as a error handling and will provide a more detailed
  8. #               error information, like error line, event that caused the error,
  9. #               description, etc.
  10. #-------------------------------------------------------------------------------
  11. # How to Use: Configure in the general configuration module the use (or not!)
  12. #             of this funcion.
  13. #-------------------------------------------------------------------------------
  14. # Special Thanks: ERZVX
  15. #-------------------------------------------------------------------------------
  16. #===============================================================================
  17.  
  18. #===============================================================================
  19. # UPDATES
  20. #-------------------------------------------------------------------------------
  21. # VX GENERAL SCRIPT EVALUATOR -> v1.0a
  22. # * In this revision, only the 'eval' scripts with a unique argument, like the
  23. #   ones generated "by the game" will pass in this basic error handling. Anyway,
  24. #   it's only recommendable to use after freeing the bugs of the scripts from
  25. #   'Script Editor', since very few scripts yet can use the command internally.
  26. # * Now the line with error is shown correctly in the message, even if the ran
  27. #   script have only one line.
  28. # * Some other minor things...
  29. #-------------------------------------------------------------------------------
  30. #===============================================================================
  31.  
  32. module PowerPackVX_General_Configs
  33.  
  34.   # Check the scripts generated by the game?
  35.   Use_Script_Evaluator = true
  36.  
  37. end
  38.  
  39. #===============================================================================
  40.  
  41. class Game_Interpreter
  42.   attr_reader :event_id
  43. end
  44.  
  45. if PowerPackVX_General_Configs::Use_Script_Evaluator == true
  46.  
  47.   alias rsmaker_script_eval eval unless $@
  48.   def eval(*args)    
  49.     n = *args.size; return rsmaker_script_eval(*args) if n > 1
  50.     begin
  51.       return rsmaker_script_eval(*args)
  52.     rescue Exception
  53.       exit if $!.class == SystemExit
  54.       desc = $!.message.split(/['\n]/)[1].sub('`'){'\''}
  55.      desc +=  "'" if $!.class == NameError      
  56.      line = $!.message.split(':')[1].to_i    
  57.      lines = *args[0].split(/\n/)
  58.      if lines.is_a? (Array)
  59.        errline = lines[(line - 1)]
  60.      else
  61.        errline = lines
  62.      end      
  63.      print "Error during the execution of the game script!\n",
  64.      "Please contact the creator of the game and inform the following:\n",
  65.      "----------------------------------------------------------------------\n",
  66.      "----------------------------------------------------------------------\n",
  67.      "Map ID: #{$game_map.map_id}\n",
  68.      "Event ID: #{$game_map.interpreter.event_id}\n",
  69.      "----------------------------------------------------------------------\n",
  70.      "----------------------------------------------------------------------\n",
  71.      "Error type: #{$!.class}\n",
  72.      "Description: \"#{desc}\"\n",
  73.      "----------------------------------------------------------------------\n",
  74.      "----------------------------------------------------------------------\n",
  75.      "Error line number: #{line}\n",      
  76.      "Line with Error: \"#{errline}\"\n",
  77.      "----------------------------------------------------------------------\n",
  78.      "----------------------------------------------------------------------\n"
  79.    end
  80.    return nil
  81.  end
  82.  
  83. end
  84.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement