Bigace360

Module RPG::Audiofile Extentions [RMXP]

May 18th, 2012
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 4.94 KB | None | 0 0
  1. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  2. # ■ Module RPG::Audiofile Extentions [RMXP]
  3. # ■ Author: Bigace360
  4. # ■ Date: May 18, 2012
  5. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  6. # Like VX, this script adds four subclasses to RPG::Audiofile, (BGM, BGS, ME,
  7. # and SE) turning it into a parent class. This is a script for developers, not
  8. # non-scripters.
  9. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  10. module RPG
  11.   #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
  12.   # ■ RPG::BGM (Data class for BGM. This class has a method to play oneself with
  13.   #             Audio module.)  
  14.   #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
  15.   class BGM < AudioFile
  16.   #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
  17.   # ■ Class Methods
  18.   #   ● RPG::BGM.last
  19.   #     Returns BGM (RPG::BGM) that playing now. If no playing BGM, returns nil.
  20.   #   ● RPG::BGM.stop
  21.   #     Stops BGM playback.
  22.   #   ● RPG::BGM.fade(time)
  23.   #     Starts BGM fadeout. time is the length of the fadeout in milliseconds.
  24.   #   ------------------------------------------------------------------------
  25.   # ■ Method
  26.   #   ● play
  27.   #     Starts the BGM playback.
  28.   #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
  29.         @@last = BGM.new
  30.         def play
  31.             if @name.empty?
  32.                 Audio.bgm_stop; @@last = BGM.new
  33.             else
  34.                 Audio.bgm_play("Audio/BGM/" + @name, @volume, @pitch)
  35.                 @@last = self
  36.             end
  37.         end
  38.         def self.stop      
  39.       Audio.bgm_stop
  40.       @@last = BGM.new
  41.     end
  42.         def self.fade(time)
  43.       Audio.bgm_fade(time)
  44.       @@last = BGM.new
  45.     end
  46.         def self.last
  47.       @@last
  48.     end
  49.     end
  50.   #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
  51.   # ■ RPG::BGS (Data class for BGS. This class has a method to play oneself with
  52.   #             Audio module.)  
  53.   #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
  54.     class BGS < AudioFile
  55.   #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
  56.   # ■ Class Methods
  57.   #   ● RPG::BGS.last
  58.   #     Returns BGS (RPG::BGS) that playing now. If no playing BGS, returns nil.
  59.   #   ● RPG::BGS.stop
  60.   #     Stops BGS playback.
  61.   #   ● RPG::BGS.fade(time)
  62.   #     Starts BGS fadeout. time is the length of the fadeout in milliseconds.
  63.   #   ------------------------------------------------------------------------
  64.   # ■ Method
  65.   #   ● play
  66.   #     Starts the BGM playback.
  67.   #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
  68.         @@last = BGS.new
  69.         def play
  70.             if @name.empty?
  71.                 Audio.bgs_stop; @@last = BGS.new
  72.             else
  73.                 Audio.bgs_play("Audio/BGS/" + @name, @volume, @pitch)
  74.                 @@last = self
  75.             end
  76.         end
  77.         def self.stop
  78.       Audio.bgs_stop
  79.       @@last = BGS.new
  80.     end
  81.         def self.fade(time)
  82.       Audio.bgs_fade(time)
  83.       @@last = BGS.new
  84.     end
  85.         def self.last
  86.       @@last
  87.     end
  88.     end
  89.   #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
  90.   # ■ RPG::ME (Data class for ME. This class has a method to play oneself with
  91.   #            Audio module.)  
  92.   #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
  93.   class ME < AudioFile
  94.   #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
  95.   # ■ Class Methods
  96.   #   ● RPG::ME.stop
  97.   #     Stops ME playback.
  98.   #   ● RPG::ME.fade(time)
  99.   #     Starts ME fadeout. time is the length of the fadeout in milliseconds.
  100.   #   ------------------------------------------------------------------------
  101.   # ■ Method
  102.   #   ● play
  103.   #     Starts the ME playback.
  104.   #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
  105.         def play
  106.             if @name.empty?
  107.         Audio.me_stop
  108.             else
  109.         Audio.me_play("Audio/ME/" + @name, @volume, @pitch)
  110.             end
  111.         end
  112.         def self.stop
  113.       Audio.me_stop
  114.     end
  115.         def self.fade(time)
  116.       Audio.me_fade(time)
  117.     end
  118.     end
  119.   #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
  120.   # ■ RPG::SE (Data class for SE. This class has a method to play oneself with
  121.   #            Audio module.)  
  122.   #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
  123.   class SE < AudioFile
  124.   #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
  125.   # ■ Class Methods
  126.   #   ● RPG::SE.stop
  127.   #     Stops SE playback.
  128.   #   ------------------------------------------------------------------------
  129.   # ■ Method
  130.   #   ● play
  131.   #     Starts the SE playback.
  132.   #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:  
  133.         def play
  134.             Audio.se_play("Audio/SE/" + @name, @volume, @pitch) unless @name.empty?
  135.         end
  136.         def self.stop
  137.       Audio.se_stop
  138.     end
  139.   end
  140. end
Advertisement
Add Comment
Please, Sign In to add comment