Advertisement
Diego-Mertens

ebs not working

Jun 22nd, 2019
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.31 KB | None | 0 0
  1. #-------------------------------------------------------------------------------
  2. # Automatic sprite name indexing for v4.3 and above
  3. #-------------------------------------------------------------------------------
  4. module EBS_SpriteConversion
  5. def self.included base
  6. base.class_eval do
  7. alias loadSpriteConversion pbStartLoadScreen if !self.method_defined?(:loadSpriteConversion)
  8. def pbStartLoadScreen(*args)
  9. # skips if not in debug mode
  10. return loadSpriteConversion(*args) if !$memDebug || Input.press?(Input::CTRL)
  11. # generates a list of all .png files
  12. allFiles = readDirectoryFiles("Graphics/Battlers/",["*.png"])
  13. files = []
  14. # pushes the necessary file names into the main processing list
  15. for i in 1..PBSpecies.maxValue
  16. next if !(getConstantName(PBSpecies,i) rescue nil)
  17. species = sprintf("%03d",i)
  18. species_name = getConstantName(PBSpecies,i)
  19. j = 0
  20. (allFiles.length).times do
  21. sprite = allFiles[j]
  22. if sprite.include?(species) || sprite.include?(species_name)
  23. files.push(sprite)
  24. allFiles.delete_at(j)
  25. else
  26. j += 1
  27. end
  28. end
  29. end
  30. # starts automatic renaming
  31. unless allFiles.empty !allFiles.include?("egg.png") && !allFiles.include?("eggCracks.png")
  32. Kernel.pbMessage("The game has detected that you're running the Elite Battle System version 4.3 or above, but have sprites in your Graphics/Battlers that do not match the new naming convention. This will break your game!")
  33. if Kernel.pbConfirmMessage("Would you like to automatically resolve this issue?")
  34. dir = "Graphics/Battlers/"
  35. # creates new directories if necessary
  36. for ext in ["Front/","Back/","FrontShiny/","BackShiny/","Eggs/"]
  37. Dir.mkdir(dir+ext) if !FileTest.directory?(dir+ext)
  38. Dir.mkdir(dir+ext+"Female/") if !FileTest.directory?(dir+ext+"Female/") && ext != "Eggs/"
  39. end
  40. for file in files
  41. user = dir+file
  42. dest = dir
  43. # generates target directory and target name
  44. if file.include?("egg") || file.include?("Egg")
  45. dest = dir+"Eggs/"
  46. if file.include?("eggCracks")
  47. new_name = file.gsub(/eggCracks/) {|s| "cracks" }
  48. elsif file.include?("Egg")
  49. new_name = file.gsub(/Egg/) {|s| "" }
  50. else
  51. new_name = file.gsub(/egg/) {|s| "" }
  52. end
  53. elsif file.include?("s")
  54. if file.include?("b")
  55. dest = dir+"BackShiny/"
  56. new_name = file.gsub(/sb/) {|s| "" }
  57. else
  58. dest = dir+"FrontShiny/"
  59. new_name = file.gsub(/s/) {|s| "" }
  60. end
  61. else
  62. if file.include?("b")
  63. dest = dir+"Back/"
  64. new_name = file.gsub(/b/) {|s| "" }
  65. else
  66. dest = dir+"Front/"
  67. new_name = file
  68. end
  69. end
  70. if file.include?("f")
  71. dest += "Female/"
  72. new_name.gsub!(/f/) {|s| "" }
  73. end
  74. target = dest+new_name
  75. # moves the files into their appropriate folders
  76. File.rename(user,target)
  77. end
  78. end
  79. # Egg conversion
  80. allFiles = readDirectoryFiles("Graphics/Battlers/",["*.png"])
  81. for file in allFiles
  82. if file == "egg.png"
  83. File.rename("Graphics/Battlers/egg.png","Graphics/Battlers/Eggs/000.png")
  84. elsif file == "eggCracks.png"
  85. File.rename("Graphics/Battlers/eggCracks.png","Graphics/Battlers/Eggs/000cracks.png")
  86. end
  87. end
  88. Kernel.pbMessage("Conversion complete! Have fun using the new system!")
  89. end
  90. # goes back to the load screen
  91. return loadSpriteConversion(*args)
  92. end
  93. end
  94. end
  95. end
  96.  
  97. if defined?(PokemonLoadScreen)
  98. PokemonLoadScreen.send(:include,EBS_SpriteConversion)
  99. end
  100.  
  101. if defined?(PokemonLoad)
  102. PokemonLoad.send(:include,EBS_SpriteConversion)
  103. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement