Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 How to get class name from Scripts.rxdata?
#2
Do you really need that backtracing script?

I have one in my project, i really don't know the scripter name (sorry dude), but the script helps me greatly: it shows the backtrace, the script names, the line and method called. And i'm writing a CMS \ CBS in my game.
Hope it helps.

To install it, just change this part of Main script...

Code:
rescue Errno::ENOENT
  
  # Aqui, definimos a mensagem padrão para Errno::ENOENT
  # Quando não é possível abrir um arquivo, a mensagem é exibida
  
  filename = $!.message.sub("Arquivo não encontrado - ", "")
  print("O Arquivo #{filename} não foi encontrado.")
end

For this.

Code:
rescue Errno::ENOENT
  
  # Aqui, definimos a mensagem padrão para Errno::ENOENT
  # Quando não é possível abrir um arquivo, a mensagem é exibida
  
  filename = $!.message.sub("Arquivo não encontrado - ", "")
  print("O Arquivo #{filename} não foi encontrado.")
  rescue StandardError => stderr
  # Bring message to user that an error has occured
  p "Your error message here. See Instructions for more details."
  # Optional, when debugging, you will still receive the error message, but in less details.
  if $DEBUG
    p stderr.message
  end
  # When?
  time = Time.now
  time = time.strftime("%a %d %b %Y, %X")
  # Write to file
  File.open("ErrorLog.rxdata","a+") do |fh|
    # Time
    fh.puts("Time: #{time}")
    # Error type
    fh.puts("Error type: #{stderr.class}")
    # In which class?
    fh.puts("Class: #{$scene.class}")
    # Message
    fh.puts("Message: #{stderr.message}")
    # Where?
    fh.puts("at")
    for location in stderr.backtrace
      # Get the section number
      section = location[/(?#Section)(\d)*(:)/]
      # Strip off anything but numbers
      section_err = section[0, section.length - 1]
      script_name = $RGSS_SCRIPTS[section_err.to_i][1]
      # Get line number
      line_num = location[/(:)(\d)*(\Z|(:))/]
      # Strip off anything but line number
      #line_num_err = line_num[section_err.length + 1, line_num.length - section_err.length]
      # Strip off ":" if any
      line_num_err = line_num[1, line_num.length - 1]
      line_num_err = line_num_err[/(\d)*/]
      # If any, get method name
      method = location[/\s\W(\w)*\W/]
      # Strip the space
      method = method[1, method.length - 1] unless method == nil
      # Now construct location string
      loc_err = script_name + ", line " + line_num_err +
        (method == nil ? "" : ", at " + method)
      # Write to file
      fh.puts("     #{loc_err}")
    end
    # Delimiter
    fh.puts("--------------------")
  end
end

The backtrace is saved in the file ErrorLog.rxdata in the project's root directory. Its a stream of characters, so any text editor can read it's data (Notepad, Wordpad, Notepad++, Sublime Text, etc).
Reply }


Messages In This Thread
RE: How to get class name from Scripts.rxdata? - by Ryaryu - 08-13-2013, 02:47 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Icon Display 1.0 scripts makes events impossible to go to events, which are passable Djigit 0 3,586 01-03-2015, 09:11 PM
Last Post: Djigit
   looking for day/night/weather scripts: Ahzoh 2 4,414 07-31-2013, 05:25 AM
Last Post: Ahzoh
   RXDATA layout? Myownfriend 4 7,042 04-09-2013, 02:17 PM
Last Post: Myownfriend
   Modifying Actor ID to Class ID for Advanced Individual Battle Commands Script NewHope 1 4,184 07-11-2012, 11:37 PM
Last Post: NewHope
   MrMo's ABS Ultimate and Other Scripts Erechel 6 8,410 05-07-2012, 03:37 AM
Last Post: Erechel
   Replace the AUDIO class for RMXP! DerVVulfman 8 13,924 10-15-2010, 06:29 PM
Last Post: yamina-chan
   Combine two scripts Kerdukie 0 3,026 12-25-2009, 02:16 AM
Last Post: Kerdukie
   Calling Scripts aistinger 3 5,231 12-03-2009, 01:41 AM
Last Post: aistinger
   Sideview Tankentai XP & SDK Scripts Ravenith 1 4,987 08-26-2009, 03:01 AM
Last Post: DerVVulfman



Users browsing this thread: