TheoAllen

Theo - Menu Sound

May 10th, 2013
434
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 4.24 KB | None | 0 0
  1. # =============================================================================
  2. # TheoAllen - Menu Sounds
  3. # Version : 1.0
  4. # Contact : www.rpgmakerid.com (or) http://theolized.blogspot.com
  5. # (This script documentation is written in informal indonesian language)
  6. # =============================================================================
  7. ($imported ||= {})[:Theo_MenuSound] = true
  8. # =============================================================================
  9. # CHANGE LOGS:
  10. # -----------------------------------------------------------------------------
  11. # 2013.05.11 - Started and Finished script
  12. # =============================================================================
  13. =begin
  14.  
  15.   Perkenalan :
  16.   Script ini ngebikin kamu setiap kali akses menu bisa puter lagu (BGM) atau
  17.   puter suara background (BGS)
  18.  
  19.   Cara pakai :
  20.   Pasang diatas main tapi dibawah material
  21.   Edit konfigurasi di bawah
  22.  
  23.   TERMS OF USE :
  24.   Credit gw, TheoAllen. Kalo semisal u bisa ngedit2 script gw trus jadi lebih
  25.   keren, terserah. Ane bebasin. Asal ngga ngeklaim aja. Kalo semisal mau
  26.   dipake buat komersil, jangan lupa, gw dibagi gratisannya.
  27.  
  28. =end
  29. # =============================================================================
  30. # Konfigurasi :
  31. # =============================================================================
  32. module THEO
  33.   module SOUND
  34.     # ------------------------------------------------------------------------
  35.     # Settingan BGM :
  36.     # ------------------------------------------------------------------------
  37.     BGM_FILENAME  = "Field1"
  38.     # Nama file untuk BGM. File harus ada di Audio/BGM
  39.     # ------------------------------------------------------------------------
  40.     BGM_VOLUME    = 100
  41.     # Volume BGM.
  42.     # ------------------------------------------------------------------------
  43.     BGM_PITCH     = 100
  44.     # Pitch BGM
  45.     # ------------------------------------------------------------------------
  46.     BGM_SWITCH    = 99
  47.     # Switch id untuk play BGM. Jika true, maka tidak akan play BGM
  48.     # ------------------------------------------------------------------------
  49.    
  50.     # ------------------------------------------------------------------------
  51.     # Settingan BGS :
  52.     # ------------------------------------------------------------------------
  53.     BGS_FILENAME  = "Clock"
  54.     # Nama file untuk BGS. File harus ada di Audio/BGS
  55.     # ------------------------------------------------------------------------
  56.     BGS_VOLUME    = 100
  57.     # Volume untuk BGS
  58.     # ------------------------------------------------------------------------
  59.     BGS_PITCH     = 100
  60.     # Pitch untuk BGS
  61.     # ------------------------------------------------------------------------
  62.     BGS_SWITCH    = 98
  63.     # Switch id untuk play BGS. Jika true, maka tidak akan play BGS
  64.     # ------------------------------------------------------------------------
  65.   end
  66. end
  67. # =============================================================================
  68. # Akhir dari konfigurasi. Setelah line ini jangan diedit kecuali ente ngerti
  69. # =============================================================================
  70. class Game_System
  71.  
  72.   alias pre_menusound_init initialize
  73.   def initialize
  74.     pre_menusound_init
  75.     @saved_bgs = nil
  76.   end
  77.  
  78.   def save_bgs
  79.     @saved_bgs = RPG::BGS.last
  80.   end
  81.  
  82.   def replay_bgs
  83.     @saved_bgs.replay if @saved_bgs
  84.   end
  85.  
  86. end
  87.  
  88. class Scene_MenuBase < Scene_Base
  89.  
  90.   include THEO::SOUND
  91.  
  92.   alias pre_menusound_start start
  93.   def start
  94.     pre_menusound_start
  95.     $game_system.save_bgm
  96.     $game_system.save_bgs
  97.     play_menu_bgm
  98.     play_menu_bgs
  99.   end
  100.  
  101.   def play_menu_bgm
  102.     return unless BGM_FILENAME.is_a?(String)
  103.     return if $game_switches[BGM_SWITCH]
  104.     path = sprintf("Audio/BGM/%s",BGM_FILENAME)
  105.     Audio.bgm_play(path, BGM_VOLUME, BGM_PITCH) rescue return
  106.   end
  107.  
  108.   def play_menu_bgs
  109.     return unless BGS_FILENAME.is_a?(String)
  110.     return if $game_switches[BGS_SWITCH]
  111.     path = sprintf("Audio/BGS/%s",BGS_FILENAME)
  112.     Audio.bgs_play(path, BGS_VOLUME, BGS_PITCH) rescue return
  113.   end
  114.  
  115. end
  116.  
  117. class Scene_Map < Scene_Base
  118.  
  119.   alias pre_menusound_start start
  120.   def start
  121.     $game_system.replay_bgm
  122.     $game_system.replay_bgs
  123.     pre_menusound_start
  124.   end
  125.  
  126. end
Advertisement
Add Comment
Please, Sign In to add comment