Command Menu Scene

From PocketWiki

Jump to: navigation, search

Contents

Command Menu Scene
File:Command_Menu_Scene.png‎
           Screen provided by Celianna
Link Command Menu Scene
Last Update
Author(s) Sky00Valentine
$imported n/a
Terms of Usage
I do not require thanks but please thank Rpgmakervx.net, Celianna, and to the PocketWiki.
Version History
n/a
Discussion and FAQ


Introduction

This script is very useful because it allows you to make your own command windows, that can do anything an event could do for you normally. It is just a way to make it look a lot better. You make a list of options and when you select one a value is stored in a variable and you choose what happens when that variable is a set number. Make things like shops, Item synthesis, and more. Not the best script at doing anyone thing but may be very good all around.

How to Use

To install this script, open up your script editor and copy/paste this script to an open slot below ▼ Materials but above ▼ Main.

Also grab this script snippet Auto Text Wrap

Read the instructions in the script

Remember to save before use.

Script Code

#===============================================================================
#
# Sky's Command Window Menu's
# Started May 5, 2010
# Completed May 6, 2010
# Updated July 3, 2010
#
#===========================================================================
#
# Features :
#    Version 1.0 - May 6, 2010
#       - Make up a whole scene based around choice menu's
#       - Easy to make your own command menu, and places
#         choice number into a variable of your choice
#    Version 1.1 - 
#       - Choices can be set to a default "Text" if they
#         require a switch that is not on(Switches not required, so only
#                                           if you use a switch)
#    Version 1.2 - July 3, 2010
#       - Can now use icons
#
#===========================================================================
#
# Credit (be sure to credit the following and rpgmakervx.net) 
# Sky00Valentine :creator and editor (You aren't required to include me, but I wouldn't mind if you did.)
#    Celianna :for requesting the script here, http://www.rpgmakervx.net/index.php?showtopic=29557
#
#===========================================================================
#
# Terms of Use
# ------------
#
#     Crediting Rpgmakervx.net and Celianna is the only thing I ask.
#     However feel free to credit Sky00Valentine if you
#     see fit. 
#
#===========================================================================
# Instructions
# ------------
# requires the SAATW script, I use it for some of my scripts so you may
# or may not already have it.
#
# for each different scene you want you will have to make another hash.
# what that means is you must make a new 
# 
#   Choice_Command_Text = {
#      "Layout"      =>     0,
#    "Variable"      =>     1,           
#       "Title"      =>    "Title of Menu",  
#      "Column"      =>    ["Left Column","Right Column"],
#        "Next"      =>    Scene_Map.new,
#             0      =>    ["1st command", "Right side of command",Switch #],
#             1      =>    ["2nd command", "Right side of 2nd command"],
#   }  NOTE: SWITCH NUMBER IS NOT REQUIRED ONLY USE IF YOU WANT THE CHOICE
#            ACTIVATED BY A SWITCH
# 
# Variable will be the variable you want to tie to your choice.  If you say
# The Variable is 3,  When the menu pops up if you choose choice 6 then the
# number 6 will be stored in the game variable 3.
# 
# When you create a new hash add a new index to the Menu_Index hash which
# includes the newly created hash.  Here is a before and after example,
# 
# Before creating a new Menu Hash:
#
# Menu_Index = {
#             0      =>     Test_Menu
# }
#
# After I made a new hash called Example_Menu I get:
#
# Menu_Index = {
#             0      =>       Test_Menu
#             1      =>    Example_Menu
# }
#
# Now to call a menu in game use the call script
# $scene = Scene_Command.new(Menu_Index)
# In the above example the Menu_Index for Test_Menu would be 0
# and the Menu_Index for Example_Menu would be 1.
# So if i use the call script
#       $scene = Scene_Command.new(0)
# then it will call the Test_Menu.
# 
# Other than that it should explain itself.
# Enjoy...
#           
# To use icons in the Command String use the following setup.
#      /i[icon index number]
# where icon number is the index of the icon
# ex. /i[4] will show icon number 4
#
#===============================================================================
module Sky
  module Text    
 
    SWITCH_OFF =  "Switch not activated" # If a switch isn't activated this text will be displayed
                              #              and if no switch was listed this will be ignored.
 
    Test_Menu = {
      "Layout"      =>    0,           # The Layout you want to use
    "Variable"      =>    1,           # Variable the choice will be stored in
       "Title"      =>    "Title of Menu",  #The Title of the Menu
      "Column"      =>    ["Left Column","Right Column"], # Names for the Columns
        "Next"      =>    Scene_Map.new,  #What scene do you want after you leave this one.
             0      =>    ["Super Potion",  "Right side of command",1], # Left command, Right Command, Switch(if needed)
             1      =>    ["2nd command",  "Right side of 2nd command"],
             2      =>    ["Just Make More", "You can leave this side empty."],
             3      =>    ["If you need",  "" ],   #empty quotes will make it blank.
             4      =>    ["A","This /i[1] Me"],
             5      =>    ["/i[20]",""],
             6      =>    ["A",""],
             7      =>    ["A",""],
             8      =>    ["A",""],
             9      =>    ["A",""],
            10      =>    ["A",""],
            11      =>    ["A",""],
            12      =>    ["A",""],
    }
 
    Other_Menu = {
      "Layout"      =>    1,           
    "Variable"      =>    1,           # Variables can be the same if you like or different
       "Title"      =>    "Another Title",  #The Title of the Menu
      "Column"      =>    ["This Column","That Column"], # Names for the Columns
        "Next"      =>    Scene_Menu.new(0),  #What scene do you want after you leave this one.
             0      =>    ["I am command 1",  "Right side of command"], # Left command, Right Command. See no switch
             1      =>    ["I am command 2",  ""],
             2      =>    ["", "You can leave the other side empty too."],
             3      =>    ["Do you get",  "it now?" ],   #empty quotes will make it blank.
    }
 
    Next_Menu = {
      "Layout"      =>    1,           
    "Variable"      =>    1,           # Variables can be the same if you like or different
       "Title"      =>    "Synthesis Shop",  #The Title of the Menu
      "Column"      =>    ["Item","Ingredients"], # Names for the Columns
        "Next"      =>    Scene_Map.new,  #What scene do you want after you leave this one.
             0      =>    ["/i[64] Super Potion",  "2x /i[65] Potion"],
             1      =>    ["/i[3] Mana Sword", "/i[64] Super Potion /i[1] Sword"],
    }
 
    Question_Menu = {
      "Layout"      =>    1,           
    "Variable"      =>    1,           # Variables can be the same if you like or different
       "Title"      =>    "What is 5 x 8",  #The Title of the Menu
      "Column"      =>    ["",""], # Names for the Columns
        "Next"      =>    Scene_Map.new,  #What scene do you want after you leave this one.
             0      =>    ["A.",  "12"],
             1      =>    ["B", "58"],
             2      =>    ["C", "13"],
             3      =>    ["D", "3"],
             4      =>    ["E", "Im stupid to still be looking"],
             5      =>    ["Trick", "What the heck is x?"],
             6      =>    ["T?", "T? Wait what?"],
    }
    Menu_Index = {
            0       =>   Test_Menu,
            1       =>   Other_Menu,
            2       =>   Next_Menu,
            3       =>   Question_Menu,
    }
  end
end
 
class SCommand_Window < Window_Selectable
  def initialize(commands)
    super(0,114,544,WLH*page_row_max+32)
    @commands = commands
    @item_max = commands.size - 5
    @index = 0
    create_contents
    refresh
    @normal = self.windowskin
    self.windowskin = Bitmap.new("Graphics/System/No_Arrow_Window") rescue self.windowskin = @normal
  end
 
  def refresh
    for i in 0...@item_max
      draw_item(i)
    end
  end
 
  def page_row_max
    return 11
  end
 
  def draw_item(index)
    rect = item_rect(index)
    rect.x += 4
    rect.width -= 8
    self.contents.clear_rect(rect)
    if @commands[index].size == 3
      self.contents.icon_text(rect.x,rect.y,rect.width,rect.height, @commands[index][0]) if $game_switches[@commands[index][2]]
      self.contents.icon_text_right(rect.y,rect.width,24, @commands[index][1]) if $game_switches[@commands[index][2]]
      self.contents.draw_text(rect, Sky::Text::SWITCH_OFF) unless $game_switches[@commands[index][2]]
    else
      self.contents.icon_text(rect.x,rect.y,rect.width,rect.height, @commands[index][0])
      self.contents.icon_text_right(rect.y,rect.width,24, @commands[index][1])
    end
  end    
end
 
class Scene_Command < Scene_Base
 
  def initialize(index)
    @menu = Sky::Text::Menu_Index[index]
  end
 
  def start
    if @menu["Layout"] == 0
      @veiwport = Viewport.new(0,0,544,416)
      @header = Window_Base.new(0,0,544,56)
      @header.contents.draw_text(0,0,508,24,@menu["Title"],1)
      @window = Window_Base.new(0,56,544,360)
      @window.contents.font.size = 32
      @window.contents.draw_text(4,16,512,36,@menu["Column"][0])
      @window.contents.draw_text(4,16,504,36,@menu["Column"][1],2)
      @window.contents.font.size = 20    
      @command_window = SCommand_Window.new(@menu)
      @command_window.z = 101
      @command_window.opacity = 0
      create_menu_background
    else
      @veiwport = Viewport.new(0,0,544,416)
      @header = Window_Base.new(0,0,544,64)
      @header.contents.font.size = 32
      @header.contents.draw_text(0,0,508,34,@menu["Title"],1)
      @header.contents.font.size = 20
      @window = Window_Base.new(0,64,544,352)
      @window.contents.font.bold = true
      @window.contents.draw_text(4,8,512,24,@menu["Column"][0])
      @window.contents.draw_text(4,8,504,24,@menu["Column"][1],2)
      @window.contents.font.bold = false    
      @command_window = SCommand_Window.new(@menu)
      @command_window.z = 101
      @command_window.opacity = 0
      create_menu_background
    end
  end
 
  def update
    @header.update
    @command_window.update
    if Input.trigger?(Input::B)
      Sound.play_cancel
      $game_variables[@menu["Variable"]] = -1
      dispose_windows
    elsif Input.trigger?(Input::C)
      if @menu[@command_window.index].size == 3
        if $game_switches[@menu[@command_window.index][2]]
          Sound.play_decision
          $game_variables[@menu["Variable"]] = @command_window.index + 1
          dispose_menu_background
          @header.dispose
          @command_window.dispose
          @window.dispose
          $scene = @menu["Next"]
        else
          Sound.play_buzzer
        end
      else
        Sound.play_decision
        $game_variables[@menu["Variable"]] = @command_window.index + 1
        @header.dispose
        @command_window.dispose
        @window.dispose
        $scene = @menu["Next"]
      end
    end
  end
 
 
  def dispose_windows
    dispose_menu_background
    @header.dispose
    @command_window.dispose
    @window.dispose
    $scene = Scene_Map.new
  end
end

Personal tools