Advertisement
LiTTleDRAgo

[RGSS/2] Custom Picture Path

Oct 21st, 2011
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 5.29 KB | None | 0 0
  1. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  2. # [Xp/Vx] Custom Picture Path
  3. # Version: 1.00
  4. # Author : LiTTleDRAgo
  5. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
  6. #------------------------------------------------------------------------------
  7. # SDK Check
  8. #------------------------------------------------------------------------------
  9. if Object.const_defined?('SDK')
  10.  SDK.log('Custom Picture Path', 'LiTTleDRAgo', 3, '19.06.11')
  11.  @custom_pict_disabled = !SDK.enabled?('Custom Picture Path')
  12. end
  13.  
  14. if !@custom_pict_disabled
  15. #==============================================================================
  16. # ** Interpreter
  17. #------------------------------------------------------------------------------
  18. #  This interpreter runs event commands. This class is used within the
  19. #  Game_System class and the Game_Event class.
  20. #==============================================================================
  21.  
  22. class Interpreter
  23.   #--------------------------------------------------------------------------
  24.   # * Alias Listing
  25.   #--------------------------------------------------------------------------
  26.   alias custom_pict_command231 command_231 if method_defined?(:command_231)
  27.   #--------------------------------------------------------------------------
  28.   # * Custom Pict
  29.   #--------------------------------------------------------------------------
  30.   def custom_pict(folder='Graphics/Pictures',file='')
  31.     @custom_pict = ['custom',folder,file]
  32.     return true
  33.   end
  34.   #--------------------------------------------------------------------------
  35.   # * command_231 (Show Picture)
  36.   #--------------------------------------------------------------------------
  37.   def command_231
  38.     @parameters[1] = @custom_pict unless @custom_pict.nil?
  39.     custom_pict_command231
  40.     @custom_pict = nil
  41.     return true
  42.   end
  43. end
  44. #==============================================================================
  45. # ** Game_Interpreter
  46. #------------------------------------------------------------------------------
  47. #  An interpreter for executing event commands. This class is used within the
  48. # Game_Map, Game_Troop, and Game_Event classes.
  49. #==============================================================================
  50.  
  51. class Game_Interpreter
  52.   #--------------------------------------------------------------------------
  53.   # * Alias Listing
  54.   #--------------------------------------------------------------------------
  55.   alias custom_pict_command231 command_231 if method_defined?(:command_231)
  56.   #--------------------------------------------------------------------------
  57.   # * Custom Pict
  58.   #--------------------------------------------------------------------------
  59.   def custom_pict(folder='Graphics/Pictures',file='')
  60.     @custom_pict = ['custom',folder,file]
  61.     return true
  62.   end
  63.   #--------------------------------------------------------------------------
  64.   # * command_231 (Show Picture)
  65.   #--------------------------------------------------------------------------
  66.   def command_231
  67.     @params[1] = @custom_pict unless @custom_pict.nil?
  68.     custom_pict_command231
  69.     @custom_pict = nil
  70.     return true
  71.   end
  72. end
  73. #==============================================================================
  74. # ** Sprite_Picture
  75. #------------------------------------------------------------------------------
  76. #  This sprite is used to display the picture.It observes the Game_Character
  77. #  class and automatically changes sprite conditions.
  78. #==============================================================================
  79. class Sprite_Picture < Sprite
  80.   #--------------------------------------------------------------------------
  81.   # * Alias Listing
  82.   #--------------------------------------------------------------------------
  83.   alias custom_pict_update update  
  84.   #--------------------------------------------------------------------------
  85.   # * name_change
  86.   #--------------------------------------------------------------------------
  87.   def name_change(name)
  88.     @name = name
  89.   end
  90.   #--------------------------------------------------------------------------
  91.   # * opacity_change
  92.   #--------------------------------------------------------------------------
  93.   def opacity_change(opacity, duration)
  94.     if duration == 0
  95.       @opacity = opacity
  96.       @target_opacity = opacity
  97.       @opacity_duration = 0
  98.     else
  99.       @target_opacity = opacity
  100.       @opacity_duration = duration
  101.     end
  102.   end
  103.   #--------------------------------------------------------------------------
  104.   # * Frame Update
  105.   #--------------------------------------------------------------------------
  106.   def update
  107.     if @picture_name != @picture.name and @picture.name[0] == 'custom'
  108.       @picture_name = @picture.name
  109.       pic1 = @picture_name[1].to_s
  110.       pic2 = @picture_name[2].to_s
  111.       self.bitmap = Cache.load_bitmap(pic1,pic2) rescue Cache.picture('')
  112.     end
  113.     custom_pict_update
  114.   end
  115. end
  116.  
  117. Cache = RPG::Cache if !defined? Cache
  118. #--------------------------------------------------------------------------
  119. # SDK Check End
  120. #--------------------------------------------------------------------------
  121. end
  122. #--------------------------------------------------------------------------
  123. # END OF SCRIPT
  124. #--------------------------------------------------------------------------
  125.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement