Go Back   The PokéCommunity Forums > Create & Discover > Game Development > Scripts & Tutorials
Reload this Page Script Cng's VX Script Thread

Notices
For all updates, view the main page.

Scripts & Tutorials This forum is for scripts and code, as well as all kinds of tutorials, software, tools and so forth. Remember to give credit!
The thread revival limit does not apply here.



Reply
 
Thread Tools
  #1    
Old April 30th, 2010 (3:55 AM).
Crazyninjaguy's Avatar
Crazyninjaguy Crazyninjaguy is offline
I'm back.
 
Join Date: May 2008
Location: England
Age: 24
Gender: Male
Posts: 663

.:Intro:.

Hiya! I'm just gonna go ahead and post all my scripts i've made for RPG Maker VX so far. I know a lot of you don't use VX, but for the minority of you who do, here they are

.:Contents:.

Random Title Music
Single Player Menu
EXP Manipulator
Slidy Menu
Battle/Map BGM Selector
Banking System

.:Credits:.

Please credit me if you use any of my scripts, they take time to write!

.:Random Title Music:.

Put this in a new script section above main, and set up the music filenames in the array. All music must be in Audio/BGM

Spoiler:
Code:
#-------------------------------------------------------------------------------
# * Play Random Title Music On Title Screen
# * By Crazyninjaguy
# * http://www.planetdev.net
#-------------------------------------------------------------------------------

BGMS = ["Town1", "Town2", "Town3"]

class Scene_Title < Scene_Base def play_title_music @length = BGMS.length @number = rand(@length) if BGMS.length > 0 Audio.bgm_play("Audio/BGM/" + BGMS[@number], 100, 100) else $data_system.title_bgm.play end RPG::BGS.stop RPG::ME.stop end end

.ingle Player Menu:.

Put it in a new script section above main.

Screenie:

Spoiler:

Script:

Spoiler:
Code:
#===============================================================================
# * Single Person Menu System
# * By Crazyninjaguy
# * http://www.planetdev.net
#-------------------------------------------------------------------------------
# ~ INSTRUCTIONS ~
#-------------------------------------------------------------------------------
# Change the variable defined in AFFINITY_VARIABLE to the variable of your
# choice. Change in game to get the effect you want.
# 0 = Normal
# 1 = Good
# 2 = Evil
#===============================================================================
ACTOR_AGE = 19
AFFINITY_VARIABLE = 1
AFFINITY_GOOD = "Good"
AFFINITY_NORMAL = "Normal"
AFFINITY_EVIL = "Evil"
HOMETOWN = "Grayridge"
class Scene_Menu < Scene_Base
  def start
    super
    create_menu_background
    create_command_window
    @face = Window_Face.new
    @name = Window_Name.new
    @bio = Window_Bio.new
  end
  def create_command_window
    s1 = Vocab::item
    s2 = Vocab::skill
    s3 = Vocab::equip
    s4 = Vocab::status
    s5 = Vocab::save
    s6 = Vocab::game_end
    @command_window = Window_Command.new(160, [s1, s2, s3, s4, s5, s6])
    @command_window.x = 384
    @command_window.index = 0
    @command_window.height = 182
    if $game_party.members.size == 0          # If number of party members is 0
      @command_window.draw_item(0, false)     # Disable item
      @command_window.draw_item(1, false)     # Disable skill
      @command_window.draw_item(2, false)     # Disable equipment
      @command_window.draw_item(3, false)     # Disable status
    end
    if $game_system.save_disabled             # If save is forbidden
      @command_window.draw_item(4, false)     # Disable save
    end
  end
  def update
    @command_window.update
    if @command_window.active
      update_command
    end
  end
  def terminate
    super
    dispose_menu_background
    @face.dispose
    @name.dispose
    @bio.dispose
    @command_window.dispose
  end
  def update_command
    if Input.trigger?(Input::B)
      Sound.play_cancel
      $scene = Scene_Map.new
    elsif Input.trigger?(Input::C)
      if $game_party.members.size == 0 and @command_window.index < 4
        Sound.play_buzzer
        return
      elsif $game_system.save_disabled and @command_window.index == 4
        Sound.play_buzzer
        return
      end
      Sound.play_decision
      case @command_window.index
      when 0      # Item
        $scene = Scene_Item.new
      when 1
        $scene = Scene_Skill.new(0)
      when 2
        $scene = Scene_Equip.new(0)
      when 3
        $scene = Scene_Status.new(0)
      when 4      # Save
        $scene = Scene_File.new(true, false, false)
      when 5      # End Game
        $scene = Scene_End.new
      end
    end
  end
end
class Window_Face < Window_Base
  def initialize
    super(0, 0, 128, 128)
    refresh
  end
  def refresh
    @actor = $game_party.members[0]
    draw_actor_face(@actor, 2, @actor.index * 96 + 2, 92)
  end
end
class Window_Name < Window_Base
  def initialize
    super(0, 128, 128, WLH + 30)
    refresh
  end
  def refresh
    @actor = $game_party.members[0]
    self.contents.draw_text(0, 0, 96, WLH, @actor.name.to_s, 1)
  end
end
class Window_Bio < Window_Base
  def initialize
    super(128, 0, 256, 182)
    refresh
  end
  def refresh
    @actor = $game_party.members[0]
    self.contents.draw_text(0, 0, 182, WLH, "Name:", 0)
    self.contents.draw_text(40, 0, 182, WLH, @actor.name.to_s, 2)
    self.contents.draw_text(0, 32, 182, WLH, "Age:", 0)
    self.contents.draw_text(40, 32, 182, WLH, ACTOR_AGE, 2)
    self.contents.draw_text(0, 64, 182, WLH, "Class:", 0)
    draw_actor_class(@actor, (182 - @actor.class.to_s.length), 63)
    self.contents.draw_text(0, 96, 182, WLH, "Affinity:", 0)
    case $game_variables[AFFINITY_VARIABLE]
    when 0
      self.contents.draw_text(40, 96, 182, WLH, AFFINITY_NORMAL, 2)
    when 1
      self.contents.draw_text(40, 96, 182, WLH, AFFINITY_GOOD, 2)
    when 2
      self.contents.draw_text(40, 96, 182, WLH, AFFINITY_EVIL, 2)
    end
    self.contents.draw_text(0, 128, 182, WLH, "Hometown:", 0)
    self.contents.draw_text(40, 128, 182, WLH, HOMETOWN, 2)
  end
end

.:EXP Manipulator:.

Includes the option to use the system with the change EXP event command.
Well this is just a small script to manipulate the exp the player recieves.

Spoiler:
Code:
#===============================================================================
# * EXP Manipulator
# * By Crazyninjaguy
# * http://www.planetdev.net
#-------------------------------------------------------------------------------
# Just set the variable in game to whatever you want.
# 0 = Normal EXP
# 1 = Double EXP
# 2 = Half EXP
# 3 = No EXP
#===============================================================================
EXP_VARIABLE = 2
USE_WITH_CHANGE_EXP = false
class Game_Troop < Game_Unit
  def exp_total
    exp = 0
    for enemy in dead_members
      exp += enemy.exp unless enemy.hidden
    end
    case $game_variables[EXP_VARIABLE]
    when 0 # Normal EXP
      total = exp
    when 1 # Double EXP
      total = exp * 2
    when 2 # Half EXP
      total = exp / 2
    when 3 # No EXP
      total = exp = 0
    end
    return total
  end
end
class Game_Interpreter
  def command_315
    value = operate_value(@params[1], @params[2], @params[3])
    iterate_actor_id(@params[0]) do |actor|
      if USE_WITH_CHANGE_EXP
        case $game_variables[EXP_VARIABLE]
        when 0
          actor.change_exp(actor.exp + value, @params[4])
        when 1
          actor.change_exp(actor.exp + value * 2, @params[4])
        when 2
          actor.change_exp(actor.exp + value / 2, @params[4])
        when 3
          value = 0
          actor.change_exp(actor.exp + value, @params[4])
        end
      else
        actor.change_exp(actor.exp + value, @params[4])
      end
    end
    return true
  end
end

.lidy Menu:.

Basically its like...a menu, and when you choose an option, another menu slides out from it.
Its better to get the demo because then all the needed pictures are there should you wish to use them.
Ok, the "docking" option means that if its enabled, the actor status window WILL NOT move when you select Skill, Equip or status. It will stay in the same position, but still slide.

Features

  • You can choose to display a picture as the background, or just normal windows.
  • You can choose whether to dock the window, or move it with the command choices.
  • You can choose whether to display the location window.
  • You can choose whether to display the gold window.
  • You can choose whether to display a picture as the background, or plane a picture.
Screenies
Spoiler:

Script
Spoiler:
Code:
#===============================================================================
#      * Slidy Menu System v0.4 *
#       By Crazyninjaguy
#       http://www.planetdev.net
# ----------------------------------------------------------------------
#        *** v0.4 Changelog ***
# ----------------------------------------------------------------------
#  * Added support for Location window which displays the name of the map
#    the player is currently on (BigEd71's Mapname Window).
#  * Added support for the Gold window which shows the amount of gold the
#    the player currently has.
#  * Added support for displaying a picture as a background image.
#  * Added support for using an image or tiled image as a background
#    planing across the screen (moving basically).
# ----------------------------------------------------------------------
#         *** Instructions ***
# ----------------------------------------------------------------------
#  * To use normal windows instead of images, set the USE_PICTURES value
#    to false.
#  * To use image as the background, set the USE_BG value to true, make sure
#    that the image defined below that is in your Graphics/Pictures folder.
#  * To use an image planing as the background, do the same as above but
#    set USE_PLANE to true.
#  * To disable the gold window set SHOW_GOLD to false.
#  * To disable the location window, set SHOW_LOCATION to false.
# ----------------------------------------------------------------------
#       *** IMPORTANT ***
# ----------------------------------------------------------------------
#  * Do not have the background image AND the planing image activated at
#    the same time. One or the other!!!
#  * If using the location window, set STATIC to true so that the actor
#    selection window does not overlap.
#===============================================================================
module CngMenuSetup
  #==============================================
  # Use a background image?
  # (544 pixels wide by 416 high)
  #==============================================
  USE_BG = false
  MENU_BACKGROUND = "Ocean"

#============================================== # OR, plane an image or tile #============================================== USE_PLANE = true PLANE_GRAPHIC = "Ocean"

#============================================== # Filename of the gold window graphic # 160 pixels wide by 64 high #============================================== GOLD_GRAPHIC = "gold_window"

#============================================== # Show the gold window? # set to true for yes and false for no #============================================== SHOW_GOLD = true

#============================================== # Filename of the mapname window graphic # 544 pixels wide by 64 high #============================================== MAPNAME_GRAPHIC = "mapname"

#============================================== # Show the location window? # set to true for yes and false for no #============================================== SHOW_LOCATION = true

#============================================== # Make the actor window static? # as in don't align with the option chosen # on the menu #============================================== STATIC = true

#============================================== # Use picture instead of windows? # set to false if no, and true for yes #============================================== USE_PICTURES = true

#============================================== # Filename of the popout menu graphic # 260 pixels wide by 290 high #============================================== POPOUT_MENU = "popout"

#============================================== # Filename of main menu graphic # 160 pixels wide by 176 high #============================================== MENU_GRAPHIC = "main_menu"

end class Scene_Menu < Scene_Base def initialize(menu_index = 0) @menu_index = menu_index end def start super create_menu_background create_command_window create_status_window if CngMenuSetup::USE_PLANE == true @plane = Plane.new @plane.bitmap = Cache.picture(CngMenuSetup::PLANE_GRAPHIC) end if CngMenuSetup::USE_BG == true @bg = Sprite.new @bg.bitmap = Cache.picture(CngMenuSetup::MENU_BACKGROUND) end if CngMenuSetup::SHOW_LOCATION == true @location = Location.new @location.x = -544 @location.y = 352 end if CngMenuSetup::SHOW_GOLD == true @gold = CngGold.new @gold.x = 544 @gold.y = 200 end if CngMenuSetup::USE_PICTURES == true @popout = Sprite.new @popout.bitmap = Cache.picture(CngMenuSetup::POPOUT_MENU) @popout.x = @status_window.x @popout.y = @status_window.y @popout.opacity = 0 @popout.z = 1 @menu = Sprite.new @menu.bitmap = Cache.picture(CngMenuSetup::MENU_GRAPHIC) @menu.x = 544 @menu.y = 0 @menu.z = 3 if CngMenuSetup::SHOW_LOCATION == true @mapname = Sprite.new @mapname.bitmap = Cache.picture(CngMenuSetup::MAPNAME_GRAPHIC) @mapname.x = @location.x @mapname.y = @location.y @mapname.z = 2 end if CngMenuSetup::SHOW_GOLD == true @gold_graphic = Sprite.new @gold_graphic.bitmap = Cache.picture(CngMenuSetup::GOLD_GRAPHIC) @gold_graphic.x = 544 @gold_graphic.y = 200 @gold_graphic.z = 3 end end @slide_back = false @slide_away = false update_slide end def terminate super dispose_menu_background @command_window.dispose @status_window.dispose if CngMenuSetup::USE_PLANE == true @plane.dispose end if CngMenuSetup::USE_BG == true @bg.dispose end if CngMenuSetup::SHOW_GOLD == true @gold.dispose if CngMenuSetup::USE_PICTURES == true @gold_graphic.dispose end end if CngMenuSetup::SHOW_LOCATION == true @location.dispose if CngMenuSetup::USE_PICTURES == true @mapname.dispose end end if CngMenuSetup::USE_PICTURES == true @popout.dispose @menu.dispose end end def update @command_window.update @status_window.update if CngMenuSetup::USE_PLANE == true @plane.ox += 1 end if CngMenuSetup::SHOW_GOLD == true @gold.update end if CngMenuSetup::SHOW_LOCATION == true @location.update end update_slide if @command_window.active update_command return end if @status_window.active update_status_window return end end def create_command_window s1 = Vocab::item s2 = Vocab::skill s3 = Vocab::equip s4 = Vocab::status s5 = Vocab::save s6 = Vocab::game_end @command_window = Window_CngMenuCommand.new(160, [s1, s2, s3, s4, s5, s6]) @command_window.index = @menu_index @command_window.x = 544 @command_window.y = 0 @command_window.z = 4 if CngMenuSetup::USE_PICTURES == true @command_window.back_opacity = 0 @command_window.opacity = 0 else @command_window.back_opacity = 200 @command_window.opacity = 255 end if $game_party.members.size == 0 # If number of party members is 0 @command_window.draw_item(0, false) # Disable item @command_window.draw_item(1, false) # Disable skill @command_window.draw_item(2, false) # Disable equipment @command_window.draw_item(3, false) # Disable status end if $game_system.save_disabled # If save is forbidden @command_window.draw_item(4, false) # Disable save end end def update_slide if $from_scene == true @command_window.x = 384 if CngMenuSetup::USE_PICTURES == true @menu.x = 384 end if CngMenuSetup::SHOW_LOCATION == true @location.x = 0 if CngMenuSetup::USE_PICTURES == true @mapname.x = 0 end end if CngMenuSetup::SHOW_GOLD == true @gold.x = 384 if CngMenuSetup::USE_PICTURES == true @gold_graphic = 384 end end elsif $from_scene == false if @command_window.x > 384 @command_window.x -= 8 if CngMenuSetup::USE_PICTURES == true @menu.x -= 8 end end if CngMenuSetup::SHOW_LOCATION == true if @location.x < 0 @location.x += 16 if CngMenuSetup::USE_PICTURES == true @mapname.x += 16 end end end if CngMenuSetup::SHOW_GOLD == true if @gold.x > 384 @gold.x -= 8 if CngMenuSetup::USE_PICTURES == true @gold_graphic.x -= 8 end end end end if @status_window.active if @status_window.x >= 126 @status_window.x -= 8 if CngMenuSetup::USE_PICTURES == true @popout.x -= 8 @popout.opacity = 255 end @status_window.visible = true end end if @slide_back == true if @status_window.x < 384 @status_window.x += 8 if CngMenuSetup::USE_PICTURES == true @popout.x += 8 @popout.opacity = 0 end @status_window.visible = true end if @status_window.x >= 384 @status_window.visible = false if CngMenuSetup::USE_PICTURES == true @popout.opacity = 0 end @slide_back = false elsif @status_window.x < 384 if CngMenuSetup::USE_PICTURES == true @popout.opacity = 255 end @status_window.visible = true end end return end def create_status_window @status_window = MenuStatus.new @status_window.x = 384 if CngMenuSetup::STATIC == true @status_window.y = 0 elsif CngMenuSetup::STATIC == false @status_window.y = 96 end @status_window.z = 2 @status_window.index = 0 @status_window.visible = false @status_window.active = false end def update_command if Input.trigger?(Input::B) Sound.play_cancel @slide_away = true $scene = Scene_Map.new end if Input.trigger?(Input::C) Sound.play_decision case @command_window.index when 0 $scene = Scene_Item.new $index = 0 $from_scene = true when 1 @status_window.active = true @status_window.contents_opacity = 255 @command_window.active = false $index = 1 if CngMenuSetup::STATIC == false @status_window.y = 45 end if CngMenuSetup::USE_PICTURES == true if CngMenuSetup::STATIC == false @popout.y = 45 end end when 2 @status_window.active = true @status_window.contents_opacity = 255 @command_window.active = false $index = 2 if CngMenuSetup::STATIC == false @status_window.y = 69 end if CngMenuSetup::USE_PICTURES == true if CngMenuSetup::STATIC == false @popout.y = 69 end end when 3 @status_window.active = true @status_window.contents_opacity = 255 @command_window.active = false $index = 3 if CngMenuSetup::STATIC == false @status_window.y = 91 end if CngMenuSetup::USE_PICTURES == true if CngMenuSetup::STATIC == false @popout.y = 91 end end when 4 $scene = Scene_File.new(true, false, false) $index = 4 $from_scene == true when 5 $scene = Scene_End.new $index = 5 $from_scene == true end end end def update_status_window update_slide if Input.trigger?(Input::B) Sound.play_cancel @slide_back = true @status_window.active = false @command_window.active = true end if Input.trigger?(Input::C) Sound.play_decision $game_party.last_actor_index = @status_window.index if $index == 1 case @status_window.index when 0...4 $scene = Scene_Skill.new(@status_window.index) $from_scene == true end end if $index == 2 case @status_window.index when 0...4 $scene = Scene_Equip.new(@status_window.index) $from_scene == true end end if $index == 3 case @status_window.index when 0...4 $scene = Scene_Status.new(@status_window.index) $from_scene == true end end end end end class MenuStatus < Window_Selectable def initialize super(0, 0, 260, 290) refresh self.index = 0 if CngMenuSetup::USE_PICTURES == true self.back_opacity = 0 self.opacity = 0 else self.back_opacity = 200 self.opacity = 255 end end def refresh self.contents.clear @item_max = $game_party.members.size for actor in $game_party.members x = 0 y = actor.index * 64 + WLH / 2 draw_actor_graphic(actor, x + 22, y + 40) draw_actor_name(actor, x + 70, y + -5) draw_actor_level(actor, x + 160, y + -5) draw_actor_hp(actor, x + 70, y + WLH * 1) end end def update_cursor if @index < 0 # No cursor self.cursor_rect.empty elsif @index < @item_max # Normal self.cursor_rect.set(0, @index * 64, contents.width, 64) elsif @index >= 100 # Self self.cursor_rect.set(0, (@index - 100) * 64, contents.width, 64) else # All self.cursor_rect.set(0, 0, contents.width, @item_max * 64) end end end class Scene_Item < Scene_Base alias cng_item_menu_terminate terminate def terminate cng_item_menu_terminate $from_scene == true end end class Scene_Skill < Scene_Base alias cng_skill_menu_terminate terminate def terminate cng_skill_menu_terminate $from_scene == true end end class Scene_Equip < Scene_Base alias cng_equip_menu_terminate terminate def terminate cng_equip_menu_terminate $from_scene == true end end class Scene_File < Scene_Base alias cng_file_menu_terminate terminate def terminate cng_file_menu_terminate $from_scene == true end end class Scene_End < Scene_Base alias cng_end_menu_terminate terminate def terminate cng_end_menu_terminate $from_scene == true end end class Scene_Map < Scene_Base alias cng_map_menu_terminate terminate def terminate cng_map_menu_terminate $from_scene == true end end class Window_CngMenuCommand < Window_Selectable attr_reader :commands # command def initialize(width, commands, column_max = 1, row_max = 0, spacing = 32) if row_max == 0 row_max = (commands.size + column_max - 1) / column_max end super(0, 0, width, row_max * WLH + 32, spacing) @commands = commands @item_max = commands.size @column_max = column_max refresh self.index = 0 end def refresh self.contents.clear for i in 0...@item_max draw_item(i) end end def draw_item(index, enabled = true) rect = item_rect(index) rect.x += 4 rect.width -= 8 self.contents.clear_rect(rect) if CngMenuSetup::USE_PICTURES == true self.contents.font.color = power_down_color else self.contents.font.color = normal_color end self.contents.font.color.alpha = enabled ? 255 : 128 self.contents.draw_text(rect, @commands[index]) end end class Window_Base < Window def draw_actor_name(actor, x, y) if CngMenuSetup::USE_PICTURES == true self.contents.font.color = power_down_color else self.contents.font.color = normal_color end self.contents.draw_text(x, y, 108, WLH, actor.name) end def draw_actor_level(actor, x, y) self.contents.font.color = system_color self.contents.draw_text(x, y, 32, WLH, Vocab::level_a) if CngMenuSetup::USE_PICTURES == true self.contents.font.color = power_down_color else self.contents.font.color = normal_color end self.contents.draw_text(x + 32, y, 24, WLH, actor.level, 2) end def draw_actor_hp(actor, x, y, width = 120) draw_actor_hp_gauge(actor, x, y, width) self.contents.font.color = system_color self.contents.draw_text(x, y, 30, WLH, Vocab::hp_a) if CngMenuSetup::USE_PICTURES == true self.contents.font.color = power_down_color else self.contents.font.color = normal_color end last_font_size = self.contents.font.size xr = x + width if width < 120 self.contents.draw_text(xr - 44, y, 44, WLH, actor.hp, 2) else self.contents.draw_text(xr - 99, y, 44, WLH, actor.hp, 2) self.contents.draw_text(xr - 55, y, 11, WLH, "/", 2) self.contents.draw_text(xr - 44, y, 44, WLH, actor.maxhp, 2) end end end class Location < Window_Base # By BigEd781, edited by CNG def initialize @map_name = load_data("Data/MapInfos.rvdata")[$game_map.map_id].name super(-544, 352, 544, 64) if CngMenuSetup::USE_PICTURES == false self.back_opacity = 200 elsif CngMenuSetup::USE_PICTURES == true self.opacity = 0 self.back_opacity = 0 end refresh end def refresh self.contents.clear self.contents.font.color = power_down_color self.contents.draw_text(0, 0, 512, 32, @map_name, 1) end def find_window_width(text) return Bitmap.new(544, 416).text_size(text).width + 48 end end class CngGold < Window_Base def initialize super(384, 176, 160, WLH + 32) if CngMenuSetup::USE_PICTURES == true self.opacity = 0 self.back_opacity = 0 end refresh end def refresh self.contents.clear draw_currency_value($game_party.gold, 4, 0, 120) end end

$from_scene = false

Demo
http://www.mediafire.com/?wzgfzwomzun[/url]

.:Battle/Map BGM Selector:.

Please not i wrote this about a year ago :D
Basically, it allows you to choose your favourite Music and either play it on the map, or play it in battle. The script itself is plug'n'play so all you have to do is paste it in a new script section, but i reccomend downloading the demo.
Screenshots:

Spoiler:




Script:
Spoiler:

Code:
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
#  * Battle BGM Selector by Crazyninjaguy
#  http://www.planetdev.co.nr
#   --------------------------------------------------------------------------
#  ** Allows you to choose the battle music from the menu
#   --------------------------------------------------------------------------
#  *** Features
#   -- Preview BGM before setting as battle bgm or map bgm
#   -- Stop playing the BGM
#   -- Set your favourite as the battle theme
#   -- Play your favourite BGM on the map
#   --------------------------------------------------------------------------
#  *** Editable Fields
#   -- Lines 87-99. The names of the BGM/Music. NOT THE FILENAME!
#   -- Lines 174,182,190,198,206,214,222,230,238,246,254,262,270
#   EXACT FILENAMES! CASE SENSITIVE!
#   --------------------------------------------------------------------------
#  *** Notes
#   -- This is my second ever script so don't expect too much lol.
#   -- Please give credit if you use this in your game.
#   -- If anything goes wrong with the script then don't hesitate to PM
#   me on my site http://www.planetdev.co.nr[/url]
#   -- Also if you have any ideas on how i could improve the script,
#   please PM me on my site http://www.planetdev.co.nr[/url]
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
module Music_Selection
  #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  #  * Constants
  #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  MUSIC_LABEL = 'Music'
  MENU_INDEX = 4
end
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
#  * This window simply displays text
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
class Window_Text < Window_Base
  def initialize
 super(0, 0, 544, 70)
 self.contents = Bitmap.new(width - 32, height - 32)
 update
  end

def update self.contents.clear self.contents.draw_text(-50, 0, 612, 42, "Which Music Would You Prefer As The Battle Music?", 1) end end #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= # * Pop-up window showing that BGM choice was saved #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= class Window_Saved < Window_Base def initialize super(120, 150, 300, 100) self.contents = Bitmap.new(width - 32, height - 32) update end

def update self.contents.clear self.contents.draw_text(0, 0, 268, 68, "BGM Selection Saved!", 1) end end #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= # * Space filling window #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= class Window_Misc < Window_Base def initialize super(272, 198, 272, 216) self.contents = Bitmap.new(width - 32, height - 32) update end

def update self.contents.clear self.contents.draw_text(0, 0, 544, 416, "Badger!", 1) end end #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= # * The options for the songs #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= class Window_Options < Window_Selectable def initialize super(272, 70, 272, 130) @commands = ["Set As Battle BGM", "Play This Song", "Stop Playing", "Play BGM On Map"] @item_max = 4 self.contents = Bitmap.new(width - 32, height - 32) refresh end

def refresh self.contents.clear for i in 0...@commands.size x = 4 y = i * 24 self.contents.draw_text(x, y, 272, 27, @commands[i]) end end end #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= # * The main scene, nothing works without this! #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= class Scene_MusicSelect def initialize(menu_index = 0) @menu_index = menu_index end

def main # Make Misc Window @window_misc = Window_Misc.new # Make Command Window #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= # * Edit name of song (Not Filename) #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= s1 = "Airship" s2 = "Field 1" s3 = "Scene 12" s4 = "Ship" s5 = "Theme 3" s6 = "Town 5" s7 = "Dungeon 4" s8 = "Battle 10" s9 = "Battle 6" s10 = "Scene 4" s11 = "Scene 6" s12 = "Scene 9" s13 = "Field 3" #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= # * End Of Editing #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= @command_window = Window_Command.new(272, [s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13]) @command_window.index = @menu_index @command_window.x = 0 @command_window.y = 70 # Make Text Window @text_window = Window_Text.new # Make Options Window @options_window = Window_Options.new # Execute transition Graphics.transition # Main loop loop do # Update game screen Graphics.update # Update input information Input.update # Frame update update # Abort loop if screen is changed if $scene != self break end end # Prepare for transition Graphics.freeze # Dispose of windows @command_window.dispose @text_window.dispose @options_window.dispose @window_misc.dispose end

def update @command_window.update @text_window.update @options_window.update @window_misc.update # If command window is active: call update_command if @command_window.active update_command return end # If options window is active: call update_options if @options_window.active update_options return end end end

def update_command # If B button was pressed if Input.trigger?(Input::B) # Play cancel SE Sound.play_cancel # Stop playing music Audio.bgm_stop # Switch to menu screen $scene = Scene_Map.new return end # If C button was pressed if Input.trigger?(Input::C) # Branch by command window cursor position case @command_window.index when 0 # Play decision SE Sound.play_decision # Make options window active @command_window.active = false @options_window.active = true @options_window.index = 0 @bgm = "Airship" # Filename, Case Sensitive when 1 # Play decision SE Sound.play_decision # Make options window active @command_window.active = false @options_window.active = true @options_window.index = 0 @bgm = "Field1" # Filename, Case Sensitive when 2 # Play decision SE Sound.play_decision # Make options window active @command_window.active = false @options_window.active = true @options_window.index = 0 @bgm = "Scene12" # Filename, Case Sensitive when 3 # Play decision SE Sound.play_decision # Make options window active @command_window.active = false @options_window.active = true @options_window.index = 0 @bgm = "Ship" # Filename, Case Sensitive when 4 # Play decision SE Sound.play_decision # Make options window active @command_window.active = false @options_window.active = true @options_window.index = 0 @bgm = "Theme3" # Filename, Case Sensitive when 5 # Play decision SE Sound.play_decision # Make options window active @command_window.active = false @options_window.active = true @options_window.index = 0 @bgm = "Town5" # Filename, Case Sensitive when 6 # Play decision SE Sound.play_decision # Make options window active @command_window.active = false @options_window.active = true @options_window.index = 0 @bgm = "Dungeon4" # Filename, Case Sensitive when 7 # Play decision SE Sound.play_decision # Make options window active @command_window.active = false @options_window.active = true @options_window.index = 0 @bgm = "Battle10" # Filename, Case Sensitive when 8 # Play decision SE Sound.play_decision # Make options window active @command_window.active = false @options_window.active = true @options_window.index = 0 @bgm = "Battle6" # Filename, Case Sensitive when 9 # Play decision SE Sound.play_decision # Make options window active @command_window.active = false @options_window.active = true @options_window.index = 0 @bgm = "Scene4" # Filename, Case Sensitive when 10 # Play decision SE Sound.play_decision # Make options window active @command_window.active = false @options_window.active = true @options_window.index = 0 @bgm = "Scene6" # Filename, Case Sensitive when 11 # Play decision SE Sound.play_decision # Make options window active @command_window.active = false @options_window.active = true @options_window.index = 0 @bgm = "Scene9" # Filename, Case Sensitive when 12 # Play decision SE Sound.play_decision # Make options window active @command_window.active = false @options_window.active = true @options_window.index = 0 @bgm = "Field3" # Filename, Case Sensitive end return end end

def update_options # If B button was pressed if Input.trigger?(Input::B) # Play cancel SE Sound.play_cancel # Make command window active @command_window.active = true @options_window.active = false @options_window.index = -1 return end # If C button was pressed if Input.trigger?(Input::C) # Branch by command window cursor position case @options_window.index when 0 # Set As Battle BGM # Play decision SE Sound.play_decision $game_system.battle_bgm = RPG::BGM.new(@bgm) Window_Saved.new Graphics.wait(60) Audio.bgm_stop $scene = Scene_Map.new when 1 # Play Song # Play decision SE Sound.play_decision Audio.bgm_play("Audio/BGM/" + @bgm, 100, 100) when 2 # Stop Playing # Play decision SE Sound.play_decision Audio.bgm_stop when 3 # Play On Map # Play decision SE Sound.play_decision Audio.bgm_play("Audio/BGM/" + @bgm, 100, 100) $scene = Scene_Map.new end return end end

.:Banking System:.

It basically allows the player to store and withdraw money at a bankpoint by calling $scene = Scene_Bank.new
Screenshots

Spoiler:

Script
Just put in a new script section above main.
Spoiler:
Code:
#===============================================================================
# * Cng's Banking System
# * By Crazyninjaguy
# * http://www.planetdev.net
#-------------------------------------------------------------------------------
# Just create two new variables, and set them up below.
# The script does the rest for you.
#
# To use this script, use a call script event command with
#
# $scene = Scene_Bank.new
#
#===============================================================================
INTERNAL_BANK = 3
BANK_VARIABLE = 4
class Scene_Bank < Scene_Base
  def start
    super
    create_menu_background
    create_main_windows
    create_command_window
  end
  def terminate
    super
    dispose_menu_background
    @command_window.dispose
    @main.dispose
    @inhand.dispose
    @banked.dispose
  end
  def update
    super
    @command_window.update
    if @command_window.active
      update_command
    end
  end
  def create_main_windows
    @main = Window_BankMessage.new("Welcome! What can i do for you?")
    @inhand = Window_InHand.new
    @inhand.y = (416 - @inhand.height)
    @banked = Window_Banked.new
    @banked.x = @inhand.width
    @banked.y = (416 - @banked.height)
  end
  def create_command_window
    s1 = "Withdraw"
    s2 = "Deposit"
    s3 = "Exit"
    @command_window = Window_Command.new(160, [s1, s2, s3])
    @command_window.index = 0
    @command_window.y = @main.y + @main.height
  end
  def update_command
    if Input.trigger?(Input::B)
      $scene = Scene_Map.new
    elsif Input.trigger?(Input::C)
      Sound.play_decision
      case @command_window.index
      when 0
        $scene = Scene_Withdraw.new
      when 1
        $scene = Scene_Deposit.new
      when 2
        $scene = Scene_Map.new
      end
    end
  end
end
class Scene_Deposit < Scene_Base
  def start
    super
    create_menu_background
    create_main_windows
  end
  def terminate
    super
    dispose_menu_background
    @number_window.dispose
    @main.dispose
  end
  def update
    super
    @number_window.update
    if Input.trigger?(Input::B)
      $scene = Scene_Bank.new
    elsif Input.trigger?(Input::C)
      Sound.play_decision
      $game_variables[INTERNAL_BANK] = @number_window.number
      $scene = Scene_Confirm.new(1)
    end
  end
  def create_main_windows
    @main = Window_BankMessage.new("How much would you like to Deposit?")
    @number_window = Window_BankInput.new
    @number_window.digits_max = 7
    @number_window.active = true
    @number_window.number = $game_variables[BANK_VARIABLE]
    @number_window.opacity = 255
    @number_window.y = @main.height
  end
end
class Scene_Withdraw < Scene_Base
  def start
    super
    create_menu_background
    create_main_windows
  end
  def terminate
    super
    dispose_menu_background
    @number_window.dispose
    @main.dispose
  end
  def update
    super
    @number_window.update
    if Input.trigger?(Input::B)
      $scene = Scene_Bank.new
    elsif Input.trigger?(Input::C)
      $game_variables[INTERNAL_BANK] = @number_window.number
      $scene = Scene_Confirm.new(2)
    end
  end
  def create_main_windows
    @main = Window_BankMessage.new("How much would you like to Withdraw?")
    @number_window = Window_BankInput.new
    @number_window.digits_max = 7
    @number_window.active = true
    @number_window.number = $game_variables[BANK_VARIABLE]
    @number_window.opacity = 255
    @number_window.y = @main.height
  end
end
class Scene_Confirm < Scene_Base
  def initialize(scene)
    @scene = scene
  end
  def start
    super
    create_menu_background
    create_main_windows
  end
  def terminate
    super
    dispose_menu_background
    @main.dispose
    @command_window.dispose
  end
  def update
    super
    @command_window.update
    if @command_window.active
      update_command
    end
  end
  def create_main_windows
    if @scene == 1
      @main = Window_BankMessage.new("Are you sure you want to deposit " + $game_variables[INTERNAL_BANK].to_s + "?")
    elsif @scene == 2
      @main = Window_BankMessage.new("Are you sure you want to withdraw " + $game_variables[INTERNAL_BANK].to_s + "?")
    end
    @command_window = Window_Command.new(160, ["Yes", "No"])
    @command_window.x = (544 - @command_window.width) / 2
    @command_window.y = 200
  end
  def update_command
    if Input.trigger?(Input::B)
      if @scene == 1
        $scene = Scene_Deposit.new
      elsif @scene == 2
        $scene = Scene_Withdraw.new
      end
    elsif Input.trigger?(Input::C)
      case @command_window.index
      when 0
        if @scene == 1
          if $game_variables[INTERNAL_BANK] > $game_party.gold
            Sound.play_buzzer
            @main.dispose
            @main = Window_BankMessage.new("Sorry, but you don't have " + $game_variables[INTERNAL_BANK].to_s + " to deposit!")
            Graphics.wait(120)
            $scene = Scene_Deposit.new
          elsif $game_variables[INTERNAL_BANK] <= $game_party.gold
            Audio.se_play("Audio/SE/Shop", 100, 100)
            $game_variables[BANK_VARIABLE] = $game_variables[INTERNAL_BANK]
            $game_party.lose_gold($game_variables[INTERNAL_BANK])
            @main.dispose
            @main = Window_BankMessage.new("Thank you, your money has been stored safely.")
            Graphics.wait(120)
            $scene = Scene_Bank.new
          end
        elsif @scene == 2
          if $game_variables[INTERNAL_BANK] > $game_variables[BANK_VARIABLE]
            @main.dispose
            @main = Window_BankMessage.new("Sorry, but you don't have " + $game_variables[INTERNAL_BANK].to_s + " to withdraw!")
            Sound.play_buzzer
            Graphics.wait(120)
            $scene = Scene_Withdraw.new
          elsif $game_variables[INTERNAL_BANK] <= $game_variables[BANK_VARIABLE]
            Audio.se_play("Audio/SE/Shop", 100, 100)
            $game_variables[BANK_VARIABLE] -= $game_variables[INTERNAL_BANK]
            $game_party.gain_gold($game_variables[INTERNAL_BANK])
            @main.dispose
            @main = Window_BankMessage.new("Thank you, " + $game_variables[INTERNAL_BANK].to_s + " has been withdrawn.")
            Graphics.wait(120)
            $scene = Scene_Bank.new
          end
        end
      when 1
        if @scene == 1
          $scene = Scene_Deposit.new
        elsif @scene == 2
          $scene = Scene_Withdraw.new
        end
      end
    end
  end
end
class Window_BankMessage < Window_Base
  def initialize(message)
    super(0, 0, 544, WLH + 40)
    @message = message
    refresh
  end
  def refresh
    self.contents.draw_text(0, 0, 512, WLH, @message, 1)
  end
end
class Window_InHand < Window_Base
  def initialize
    super(0, 0, 160, WLH + 62)
    refresh
  end
  def refresh
    self.contents.clear
    self.contents.font.color = system_color
    self.contents.draw_text(0, 0, 136, WLH, "In Hand", 0)
    self.contents.font.color = normal_color
    draw_currency_value($game_party.gold, 4, 32, 120)
  end
end
class Window_Banked < Window_Base
  def initialize
    super(0, 0, 160, WLH + 62)
    refresh
  end
  def refresh
    self.contents.clear
    self.contents.font.color = system_color
    self.contents.draw_text(0, 0, 136, WLH, "In Bank", 0)
    self.contents.font.color = normal_color
    draw_currency_value($game_variables[BANK_VARIABLE], 4, 32, 120)
  end
end
class Window_BankInput < Window_Base
  def initialize
    super(0, 0, 190, 64)
    @number = 0
    @digits_max = 6
    @index = 0
    self.opacity = 0
    self.active = false
    self.z += 9999
    refresh
    update_cursor
  end
  def number
    return @number
  end
  def number=(number)
    @number = [[number, 0].max, 10 ** @digits_max - 1].min
    @index = 0
    refresh
  end
  def digits_max
    return @digits_max
  end
  def digits_max=(digits_max)
    @digits_max = digits_max
    refresh
  end
  def cursor_right(wrap)
    if @index < @digits_max - 1 or wrap
      @index = (@index + 1) % @digits_max
    end
  end
  def cursor_left(wrap)
    if @index > 0 or wrap
      @index = (@index + @digits_max - 1) % @digits_max
    end
  end
  def update
    super
    if self.active
      if Input.repeat?(Input::UP) or Input.repeat?(Input::DOWN)
        Sound.play_cursor
        place = 10 ** (@digits_max - 1 - @index)
        n = @number / place % 10
        @number -= n * place
        n = (n + 1) % 10 if Input.repeat?(Input::UP)
        n = (n + 9) % 10 if Input.repeat?(Input::DOWN)
        @number += n * place
        refresh
      end
      last_index = @index
      if Input.repeat?(Input::RIGHT)
        cursor_right(Input.trigger?(Input::RIGHT))
      end
      if Input.repeat?(Input::LEFT)
        cursor_left(Input.trigger?(Input::LEFT))
      end
      if @index != last_index
        Sound.play_cursor
      end
      update_cursor
    end
  end
  def refresh
    self.contents.clear
    self.contents.font.color = normal_color
    s = sprintf("%0*d", @digits_max, @number)
    for i in 0...@digits_max
      self.contents.draw_text(24 + i * 16, 0, 16, WLH, s[i,1], 1)
    end
  end
  def update_cursor
    self.cursor_rect.set(24 + @index * 16, 0, 16, WLH)
  end
end

There are more, but theres a character limit :L
Go here to see them all: http://www.planetdev.net/index.php?/forum/24-scripts/

Reply With Quote

Relevant Advertising!

  #2    
Old April 30th, 2010 (4:00 AM).
The Dewitty's Avatar
The Dewitty The Dewitty is offline
Developing an awesome game.
 
Join Date: Jul 2009
Location: Netherlands
Age: 20
Gender: Male
Nature: Sassy
Posts: 259

Awesome! Too bad I don't use RPGVX.. I'd definitely use em.

__________________

~Ledyba~
Reply With Quote
  #3    
Old April 30th, 2010 (4:02 AM).
Crazyninjaguy's Avatar
Crazyninjaguy Crazyninjaguy is offline
I'm back.
 
Join Date: May 2008
Location: England
Age: 24
Gender: Male
Posts: 663

Thanks

As i said at the bottom of the topic, there is more but this forum has a character limit :L

Reply With Quote
Reply
Quick Reply

Sponsored Links
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -8. The time now is 11:37 PM.