RPGXP スクリプト
2013.10.01 06:15

Initial Switches and Variables

閲覧数 917 推奨数 0 コメント 0
?

Shortcut

Prev前へ 書き込み

Next次へ 書き込み

Larger Font Smaller Font 上へ 下へ Go comment 印刷
?

Shortcut

Prev前へ 書き込み

Next次へ 書き込み

Larger Font Smaller Font 上へ 下へ Go comment 印刷
=begin

 Initial Switches and Variables (aka Autoswitcher 3)
 by PK8
 Created: 5/8/2012
 Modified: -
 ──────────────────────────────────────────────────────────────────────────────
 ■ Table of Contents
   o Author's Notes                                - Line 16-19
   o Introduction                                  - Line 21-22
   o Features                                      - Line 24-26
   o Methods Aliased                               - Line 28-30
   o Changelog                                     - Line 32-45
   o Usage                                         - Line 47-69
 ──────────────────────────────────────────────────────────────────────────────
 ■ Author's Notes
   This version's a major improvement over my last two versions as they offer
   shortcuts in an effort to streamline the process of setting up certain
   variables and switches.
 ──────────────────────────────────────────────────────────────────────────────
 ■ Introduction
   This script allows users to set the initial values of switches and variables.
 ──────────────────────────────────────────────────────────────────────────────
 ■ Features
   Set which switches can turn on / off at the start of your game.
   Set the initial values of any or all variables.
 ──────────────────────────────────────────────────────────────────────────────
 ■ Methods Aliased
   Game_Switches.initialize
   Game_Variables.initialize
 ──────────────────────────────────────────────────────────────────────────────
 ■ Changelog
   v1p  (2/28/2008): My first time making this. It involved creating a scene
                     which users had to edit in which switches and variables
                     to adjust, and a direct edit to Scene_Title. I'm not too
                     proud of it. (I didn't have much knowledge then.)
   v1z  (?/??/????): This came about when I was looking for a better way to
                     do it in SephirothSpawn's old forums. Both Seph and
                     Zeriab provided answers, but Seph's answer appeared
                     a little too complex for me at the time so I chose
                     Zeriab's. Known as "Zeriab's Autoswitcher"
   v2   (7/12/2009): Improves upon the original by adding new switch/variable
                     settings to the script.
   v3   (5/8/2012) : Improves upon v2 by adding new shortcuts to streamline the
                     process of setting up initial switches and variables.
 ──────────────────────────────────────────────────────────────────────────────
 ■ Usage
   Data[key] = value
   * Data represents Switch or Variable
   * key represents the ID of the switch or variable
   * value represents the value of the Switch/Variable ID.
   
   In this version, there are 3 shortcuts you can use besides specifying an ID
   for a variable or switch. That would mean there are 4 ways to set the
   initial values for your switches and variables.
   
     Type      Code Example         Description
     ─────────┬────────────────────────┬───────────────────────────────────────
      Integer │ Data[1] = value        │ Sets new value to a single switch or
              │                        │ variable ID. Example: 1
      Range   │ Data[1..5] = value     │ Sets new value to a range of switch
              │                        │ or variable IDs. Example: 1,2,3,4,5
      Array   │ Data[1,4..6,8] = value │ Sets new value to a group of switch
              │                        │ or variable IDs. Item can be an Integer
              │                        │ or a range. Example: 1,4,5,6,8
      Nil     │ Data[nil] = value      │ Sets new value to all switch or
              │                        │ variable IDs.
     ─────────┴────────────────────────┴───────────────────────────────────────
                                         
=end

module PK8
  class Initial
    #--------------------------------------------------------------------------
    # * Do not modify
    #--------------------------------------------------------------------------
    Switch, Variable = {}, {}
    
    #--------------------------------------------------------------------------
    # * Switch/Variable[id] = value
    # id can be an integer, a range, an array, or nil.
    #--------------------------------------------------------------------------
    Switch[1]     = true
    Variable[1]   = 50

    #--------------------------------------------------------------------------
    # * Do not modify
    #--------------------------------------------------------------------------
    file_ext = "rxdata" # It's just there to make porting easier (I'm lazy).
    
    if Switch.has_key?(nil)
      for i in 1...load_data("Data/System.#{file_ext}").switches.size
        Switch[i] = Switch[nil]
      end
      Switch.delete(nil)
    end
    Switch.each { |k, v|
      if k.is_a?(Range); for i in k; Switch[i] = v; end; Switch.delete(k)
      elsif k.is_a?(Array)
        k.each { | i |
          if i.is_a?(Integer); Switch[i] = v
          elsif i.is_a?(Range); for i2 in i; Switch[i2] = v; end
          end }
        Switch.delete(k)
      end
    }
    if Variable.has_key?(nil)
      for i in 1...load_data("Data/System.#{file_ext}").variables.size
        Variable[i] = Variable[nil]
      end
      Variable.delete(nil)
    end
    Variable.each { |k, v|
      if k.is_a?(Range); for i in k; Variable[i] = v; end; Variable.delete(k)
      elsif k.is_a?(Array)
        k.each { | i |
          if i.is_a?(Integer); Variable[i] = v
          elsif i.is_a?(Range); for i2 in i; Variable[i2] = v; end
          end }
        Variable.delete(k)
      end
    }
  end
end

#==============================================================================
# ** Game_Switches
#------------------------------------------------------------------------------
#  This class handles switches. It's a wrapper for the built-in class "Array."
#  Refer to "$game_switches" for the instance of this class.
#==============================================================================

class Game_Switches
  #--------------------------------------------------------------------------
  # * Do not modify
  #--------------------------------------------------------------------------
  unless method_defined?(:pk8_initialswitches_initialize)
    alias_method(:pk8_initialswitches_initialize, :initialize)
  end
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    pk8_initialswitches_initialize
    PK8::Initial::Switch.each { |k, v| @data[k] = v }
  end
end

#==============================================================================
# ** Game_Variables
#------------------------------------------------------------------------------
#  This class handles variables. It's a wrapper for the built-in class "Array."
#  Refer to "$game_variables" for the instance of this class.
#==============================================================================

class Game_Variables
  #--------------------------------------------------------------------------
  # * Do not modify
  #--------------------------------------------------------------------------
  unless method_defined?(:pk8_initialvariables_initialize)
    alias_method(:pk8_initialvariables_initialize, :initialize)
  end
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    pk8_initialvariables_initialize
    PK8::Initial::Variable.each { |k, v| @data[k] = v }
  end
end
 
게임 시작시 변수의 초기값과 스위치의 on/off 여부를 지정할 수 있는 스크립트입니다
?

List of Articles
番号 カテゴリ タイトル 投稿者 日付 閲覧数 推奨数
288 RPGXP スクリプト 새로운 게임 시작/로드 시 미묘한 연출 추가. 창조도시 2007.12.01 2552 1
287 RPGXP スクリプト 대화 글씨 폰트를 원하는 폰트로 바꾸기 창조도시 2007.12.01 1677 2
286 RPGXP スクリプト 대각선 방향 이동추가로 8방향 이동 만들기. 1 창조도시 2008.08.14 2455 1
285 RPGXP スクリプト 맵 이름을 화면 상단에 띄우기. 1 1 file 창조도시 2008.10.12 2410 1
284 RPGXP スクリプト 최초 시작화면에 제작자 정보를 띄워보자. 6 창조도시 2008.04.04 2210 5
283 RPGXP スクリプト 선택 메뉴를 가운데 정렬 해보자. 1 file 창조도시 2007.12.02 1670 2
282 RPGXP スクリプト 아이템창을 아이템 분류별로 나누어 지게 개조. 3 file 창조도시 2007.12.02 1878 1
281 RPGXP スクリプト c[n] 명령어 줄때의 색상 결정. 창조도시 2008.02.14 1341 1
280 RPGXP スクリプト 대화창에 얼굴 띄우기& 대화창 명령어 모음. 1 file 창조도시 2008.12.31 2360 1
279 RPGXP スクリプト 게임도중에 글씨체를 바꿔보자. 창조도시 2008.12.31 1541 1
278 RPGXP スクリプト 대화창에 이름&얼굴 띄우기 새로운방식. file 창조도시 2007.11.06 3884 3
277 RPGXP スクリプト 그림자문자 사용하기.. 바탕색이 무슨색이건 상관없이 글자가 잘보인다!!! 창조도시 2007.11.06 1703 1
276 RPGXP スクリプト 기차 파티 스크립트 2 창조도시 2008.07.24 1708 2
275 RPGXP スクリプト 한글이름입력기 v1.76 1 1 창조도시 2008.07.24 2933 2
274 RPGXP スクリプト 창고 시스템 2 창조도시 2008.01.18 2012 3
273 RPGXP スクリプト 물가에가면 캐릭터를 반사시켜주는 스크립트 4 file 창조도시 2007.12.02 4786 6
272 RPGXP スクリプト 파티 선두 캐릭터 id 변수에 넣기 Evangelista 2008.01.08 1668 1
271 RPGVX スクリプト vx 한글이름입력 2 file 가가상 2010.05.21 3352 1
270 RPGVX スクリプト [VX] 파티 선두 캐릭터 액터ID를 변수에 넣기 Evangelista 2008.11.28 1963 1
269 RPGVX スクリプト [VX] 조건분기로 키입력의 처리 실행 1 Evangelista 2008.11.28 1996 1
Board Pagination Prev 1 2 3 4 5 6 7 8 9 10 ... 15 Next
/ 15