VX 스크립트

name.JPG

사용법 :
1. 스크립트 에디터를 여시고. 왼쪽 메뉴에서 (이 곳에 추가) 라고 된 곳을 찾아서 마우스 우측클릭, 삽입
2. 새 페이지 오른쪽 부분에 아래 스크립트 부분을 복사해서 붙여넣기
3. 복사, 붙여넣기하면 생기는 출처와 관련된 마지막줄 삭제
4. 이벤트 작성, 이름 입력의 처리

버그라던가 문제점 발견되면 댓글 남겨두시면 확인하고 수정합니다.
좋은 게임들 만드세요.

이하 스크립트 입니다.

#==============================================================================
# ■ Window_NameEdit
#------------------------------------------------------------------------------
# 이름 입력 화면에서, 이름을 편집하는 윈도우입니다.
#==============================================================================

class Window_NameEdit < Window_Base
  #---------------------------------------------------------------------------
  # ● 정수 
  CONSO = ["ㄱ","ㄲ","ㄳ","ㄴ","ㄵ","ㄶ","ㄷ","ㄸ","ㄹ","ㄺ","ㄻ","ㄼ","ㄽ","ㄾ","ㄿ","ㅀ","ㅁ","ㅂ","ㅃ","ㅄ","ㅅ","ㅆ","ㅇ","ㅈ","ㅉ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"]
  HEAD = ["ㄱ","ㄲ","ㄴ","ㄷ","ㄸ","ㄹ","ㅁ","ㅂ","ㅃ","ㅅ","ㅆ","ㅇ","ㅈ","ㅉ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"]
  TABLE = ["ㄱ","ㄲ","ㄳ","ㄴ","ㄵ","ㄶ","ㄷ","ㄹ","ㄺ","ㄻ","ㄼ","ㄽ","ㄾ","ㄿ","ㅀ","ㅁ","ㅂ","ㅄ","ㅅ","ㅆ","ㅇ","ㅈ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"]
  TABLE_SIDE = ["ㄱ","ㄴ","ㄹ","ㅂ"]
  ANOTHER_TABLE_SIDE = [[nil,"ㅅ"],["ㅈ","ㅎ"],["ㄱ","ㅁ","ㅂ","ㅅ","ㅌ","ㅍ","ㅎ"],[nil,"ㅅ"]]
  VOWEL = ["ㅏ","ㅐ","ㅑ","ㅒ","ㅓ","ㅔ","ㅕ","ㅖ","ㅗ","ㅘ","ㅙ","ㅚ","ㅛ","ㅜ","ㅝ","ㅞ","ㅟ","ㅠ","ㅡ","ㅢ","ㅣ"]
  COM_VOWEL = ["ㅗ","ㅜ","ㅡ"]
  ANOTHER_COM_VOWEL = [["ㅏ","ㅐ","ㅣ"],["ㅓ","ㅔ","ㅣ"],"ㅣ"] 
  #--------------------------------------------------------------------------
  # ● 공개 인스턴스 변수
  #--------------------------------------------------------------------------
  attr_reader   :name                     # 이름
  attr_reader   :prompt                     # 프롬프트
  attr_reader   :index                     # 커서 위치
  attr_reader   :max_char               # 최대 문자수
  #--------------------------------------------------------------------------
  # ● 오브젝트 초기화
  #     actor    : 액터
  #     max_char : 최대 문자수
  #--------------------------------------------------------------------------
  def initialize(actor, max_char)
    super(88, 84, 368, 128)
    @actor = actor
    @prompt = []
    @max_char = max_char
    name_array = actor.name.split(//)[0...@max_char]   # 최대 문자수에 거둔다
    @name = []
    @default_name = []
    for i in 0...name_array.size
      @name << name_array[i]
      @default_name << name_array[i]
    end
    self.active = false
    refresh
  end
  #--------------------------------------------------------------------------
  # ● 디폴트의 이름에 되돌린다
  #--------------------------------------------------------------------------
  def restore_default
    @name = @default_name.dup
    @prompt = []   
    refresh
  end
  #--------------------------------------------------------------------------
  # ● 문자의 추가
  #     character : 추가하는 문자
  #--------------------------------------------------------------------------
  def add(character)
    @prompt << character
    refresh
  end
  #--------------------------------------------------------------------------
  # ● 문자의 삭제
  #--------------------------------------------------------------------------
  def back
    @prompt == [] ? @name.pop : @prompt.pop
    refresh
  end
  #--------------------------------------------------------------------------
  # ● 항목을 묘화 하는 구형의 취득
  #     index : 항목 번호
  #--------------------------------------------------------------------------
  def item_rect(index)
    rect = Rect.new(0, 0, 0, 0)
    rect.x = 220 - (@max_char + 1) * 12 + index * 24
    rect.y = 36
    rect.width = 24
    rect.height = WLH
    return rect
  end
  #--------------------------------------------------------------------------
  # ● 리프레쉬
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    draw_actor_face(@actor, 0, 0)
    name = prompt_to_letter
    if @name.size == @max_char
          @prompt = []
          name = ""
          @index = @name.size - 1
    else
          @index = @name.size
    end
    for i in 0...@name.size
      self.contents.draw_text(item_rect(i), @name[i], 1)
    end
    self.contents.draw_text(item_rect(@name.size), name, 1)
    update_cursor
  end
  #--------------------------------------------------------------------------
  # ● 커서의 갱신
  #--------------------------------------------------------------------------
  def update_cursor
    self.cursor_rect = item_rect(@index)
  end
  #--------------------------------------------------------------------------
  # ● 프레임 갱신
  #--------------------------------------------------------------------------
  def update
    super
    update_cursor
  end
 
#==============================================================================
# ■ prompt_to_letter, 1st~5th phase, where?(array = from, c = what)
#------------------------------------------------------------------------------
# 이 이하는 글자를 조합하는 내용입니다.
# 다른 부분은 관계없지만, 이 이하의 부분은 수정하지 않길 권장합니다.
# 일부 폰트에서 특정 문자가 표현되지 않습니다. (삃,쮃 등등..)
#
# 2009. 3. 18 by Heircoss
#==============================================================================
  def prompt_to_letter
    size = @prompt.size
    case size
    when 0
          return ""
    when 1
          return @prompt[0]
    when 2
          first_phase
    when 3
          second_phase
    when 4
          third_phase
    when 5
          fourth_phase
    when 6
          fifth_phase
    end
  end
  def first_phase
    if CONSO.include?(@prompt[0])
          if CONSO.include?(@prompt[1])
                c0, c1 = conso_plus_conso
          else
                return conso_plus_vowel
          end
    else
          c0, c1 = vowel_plus_vowel
    end
    if c1 == nil
          return c0
    else
          @name << @prompt.shift
    end                   
    return @prompt[0]
  end
  def second_phase
    if CONSO.include?(@prompt[0])
          if CONSO.include?(@prompt[1])
                if CONSO.include?(@prompt[2])
                      @name << conso_plus_conso(@prompt.shift, @prompt.shift)
                else
                      @name << @prompt.shift
                      return conso_plus_vowel
                end
          else
                if TABLE.include?(@prompt[2])
                      return conso_plus_vowel_plus_table
                else
                      c0, c1 = vowel_plus_vowel(@prompt[1], @prompt[2])
                      if c1 == nil
                            return conso_plus_vowel(@prompt[0],c0)
                      else
                            @name << conso_plus_vowel(@prompt.shift, @prompt.shift)
                      end 
                end
          end
    else
          @name << vowel_plus_vowel(@prompt.shift, @prompt.shift)
    end
    return @prompt[0]
  end
  def third_phase
    if CONSO.include?(@prompt[2])
          if CONSO.include?(@prompt[3])
                c0, c1 = conso_plus_conso(@prompt[2], @prompt[3])
                if c1 == nil
                      conso, vowel, table = @prompt[0],@prompt[1],c0
                      return conso_plus_vowel_plus_table(conso, vowel, table)
                else
                      conso, vowel, table = @prompt.shift, @prompt.shift, @prompt.shift
                      @name << conso_plus_vowel_plus_table(conso, vowel, table)
                end           
          else
                conso, vowel = @prompt.shift, @prompt.shift
                @name << conso_plus_vowel(conso, vowel)
                return  conso_plus_vowel
          end
    else
          if TABLE.include?(@prompt[3])
                conso = @prompt[0]
                vowel = vowel_plus_vowel(@prompt[1], @prompt[2])
                table = @prompt[3]
                return conso_plus_vowel_plus_table(conso, vowel, table)
          else
                conso = @prompt.shift
                vowel = vowel_plus_vowel(@prompt.shift, @prompt.shift)
                @name << conso_plus_vowel(conso, vowel)
          end
    end
    return @prompt[0]
  end
  def fourth_phase
    if CONSO.include?(@prompt[4])
          if CONSO.include?(@prompt[2])
                conso = @prompt.shift
                vowel = @prompt.shift
                table = conso_plus_conso(@prompt.shift,@prompt.shift)
                @name << conso_plus_vowel_plus_table(conso, vowel, table)
          else
                c0, c1 = conso_plus_conso(@prompt[3], @prompt[4])
                if c1 == nil
                      conso = @prompt[0]
                      vowel = vowel_plus_vowel(@prompt[1], @prompt[2])
                      table =  c0
                      return conso_plus_vowel_plus_table(conso, vowel, table)
                else
                      conso = @prompt.shift
                      vowel = vowel_plus_vowel(@prompt.shift, @prompt.shift)
                      table = @prompt.shift
                      @name << conso_plus_vowel_plus_table(conso, vowel, table)
                end
          end
    else
          @name << second_phase
          @prompt = @prompt[3..4]
          return first_phase
    end
    return @prompt[0]   
  end
  def fifth_phase
    if CONSO.include?(@prompt[5])
      conso = @prompt.shift
      vowel = vowel_plus_vowel(@prompt.shift, @prompt.shift)
      table = conso_plus_conso(@prompt.shift, @prompt.shift)
      @name << conso_plus_vowel_plus_table(conso, vowel, table)
    else
      @name << third_phase
      @prompt = @prompt[4..5]
      return first_phase
    end
    return @prompt[0]
  end
  def conso_plus_conso(c0 = @prompt[0], c1 = @prompt[1])
    index0 = where?(TABLE_SIDE,c0)
    if index0 != nil
          index1 = where?(ANOTHER_TABLE_SIDE[index0],c1)
          if index1 != nil
                index0 = where?(CONSO, c0)
                return CONSO[index0 + index1 + 1]
          end
    end
    return c0, c1
  end
  def vowel_plus_vowel(c0 = @prompt[0], c1 = @prompt[1])
    index0 = where?(COM_VOWEL,c0)
    if index0 != nil
          index1 = where?(ANOTHER_COM_VOWEL[index0],c1)
          if index1 != nil
                index0 = where?(VOWEL, c0)
                return VOWEL[index0 + index1 + 1]
          end
    end
    return c0, c1                  
  end                   
  def conso_plus_vowel(c0 = @prompt[0], c1 = @prompt[1])
    index0 = where?(HEAD,c0)
    index1 = where?(VOWEL,c1)                         
    return [44032 + (588 * index0) + (28 * index1)].pack('U*')
  end
  def conso_plus_vowel_plus_table(c0 = @prompt[0], c1 = @prompt[1], c2 = @prompt[2])
    index0 = where?(HEAD,c0)
    index1 = where?(VOWEL,c1)
    index2 = where?(TABLE,c2)
    return [44032 + (588 * index0) + (28 * index1) + index2 + 1].pack('U*')
  end
  def where?(array, c)
    if array.class != Array && array == c
          return 0
    else
          array.each_with_index do |item, index|
                return index if item == c
          end
    end
    return nil
  end             
end
#==============================================================================
# ■ 여기까지
#==============================================================================

#==============================================================================
# ■ Window_NameInput
#------------------------------------------------------------------------------
# 이름 입력 화면에서, 문자를 선택하는 윈도우입니다.
#==============================================================================

class Window_NameInput < Window_Base
  #--------------------------------------------------------------------------
  # ● 문자표
  # 이하 TABLE의 순서를 바꾸는 것은 스크립트의 실행에 큰 영향을 주지 않습니다.
  # 다만 영어나 숫자, 기타 기호등을 집어넣을 경우는 기본적으로는 실행이 되겠지만,
  # 혹시나 버그등이 발생할 수도 있습니다.
  # 물론 입력할 문자등을 늘리는 이유로 칸이 부족해 창의 크기를 늘려야 한다면,
  # 창의 x, y ,width, height 값을 적당히 조절하시고,
  # VER_LINE, HOR_LINE, CONFIRM 또한 맞게 수정하셔야 합니다.
  #--------------------------------------------------------------------------
  TABLE = [ 'ㅂ','ㅈ','ㄷ','ㄱ','ㅅ', 'ㅛ','ㅕ','ㅑ','ㅐ','ㅔ',
              'ㅃ','ㅉ','ㄸ','ㄲ','ㅆ',  '','','','ㅒ','ㅖ',
              'ㅁ','ㄴ','ㅇ','ㄹ','ㅎ', 'ㅗ','ㅓ','ㅏ','ㅣ','',
              'ㅋ','ㅌ','ㅊ','ㅍ','','ㅠ','ㅜ','ㅡ','','결정']
  VER_LINE = 4 #수직방향의 갯수
  HOR_LINE = 10 #수평방향의 갯수
  CONFIRM = 39 #결정 키 의 위치
  #--------------------------------------------------------------------------
  # ● 오브젝트 초기화
  #--------------------------------------------------------------------------
  def initialize
    super(88, 212, 368, 128)
    @index = 0
    refresh
    update_cursor
  end
  #--------------------------------------------------------------------------
  # ● 문자의 취득
  #--------------------------------------------------------------------------
  def character
    return TABLE[@index]
  end
  #--------------------------------------------------------------------------
  # ● 커서 위치 결정 판정
  #--------------------------------------------------------------------------
  def is_decision
    return (@index == CONFIRM)
  end
  #--------------------------------------------------------------------------
  # ● 항목을 묘화 하는 구형의 취득
  #     index : 항목 번호
  #--------------------------------------------------------------------------
  def item_rect(index)
    rect = Rect.new(0, 0, 0, 0)
    rect.x = index % 10 * 32 + index % 10 / 5 * 16
    rect.y = index / 10 * WLH
    rect.width = 32
    rect.height = WLH
    return rect
  end
  #--------------------------------------------------------------------------
  # ● 리프레쉬
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    for i in 0...TABLE.size
      rect = item_rect(i)
      rect.x += 2
      rect.width -= 4
      self.contents.draw_text(rect, TABLE[i], 1)
    end
  end
  #--------------------------------------------------------------------------
  # ● 커서의 갱신
  #--------------------------------------------------------------------------
  def update_cursor
    self.cursor_rect = item_rect(@index)
  end
  #--------------------------------------------------------------------------
  # ● 커서를 아래에 이동
  #     wrap : rack-around 허가
  #--------------------------------------------------------------------------
  def cursor_down(wrap)
    if @index < VER_LINE * HOR_LINE - HOR_LINE
      @index += HOR_LINE
    elsif wrap
      @index -= VER_LINE * HOR_LINE - HOR_LINE
    end
  end
  #--------------------------------------------------------------------------
  # ● 커서를 위에 이동
  #     wrap : rack-around 허가
  #--------------------------------------------------------------------------
  def cursor_up(wrap)
    if @index >= HOR_LINE
      @index -= HOR_LINE
    elsif wrap
      @index += VER_LINE * HOR_LINE - HOR_LINE
    end
  end
  #--------------------------------------------------------------------------
  # ● 커서를 오른쪽으로 이동
  #     wrap : rack-around 허가
  #--------------------------------------------------------------------------
  def cursor_right(wrap)
    if @index % HOR_LINE < (HOR_LINE - 1)
      @index += 1
    elsif wrap
      @index -= (HOR_LINE - 1)
    end
  end
  #--------------------------------------------------------------------------
  # ● 커서를 왼쪽으로 이동
  #     wrap : rack-around 허가
  #--------------------------------------------------------------------------
  def cursor_left(wrap)
    if @index % HOR_LINE > 0
      @index -= 1
    elsif wrap
      @index += (HOR_LINE - 1)
    end
  end
  #--------------------------------------------------------------------------
  # ● 커서를 결정에 이동
  #--------------------------------------------------------------------------
  def cursor_to_decision
    @index = CONFIRM
  end
  #--------------------------------------------------------------------------
  # ● 프레임 갱신
  #--------------------------------------------------------------------------
  def update
    super
    last_mode = @mode
    last_index = @index
    if Input.repeat?(Input::DOWN)
      cursor_down(Input.trigger?(Input::DOWN))
    end
    if Input.repeat?(Input::UP)
      cursor_up(Input.trigger?(Input::UP))
    end
    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 Input.trigger?(Input::A)
      cursor_to_decision
    end
    if @index != last_index
      Sound.play_cursor
    end
    update_cursor
  end
end

#==============================================================================
# ■ Scene_Name
#------------------------------------------------------------------------------
# 이름 입력 화면의 처리를 실시하는 클래스입니다.
#==============================================================================

class Scene_Name < Scene_Base
  #--------------------------------------------------------------------------
  # ● 개시 처리
  #--------------------------------------------------------------------------
  def start
    super
    create_menu_background
    @actor = $game_actors[$game_temp.name_actor_id]
    @edit_window = Window_NameEdit.new(@actor, $game_temp.name_max_char)
    @input_window = Window_NameInput.new
  end
  #--------------------------------------------------------------------------
  # ● 종료 처리
  #--------------------------------------------------------------------------
  def terminate
    super
    dispose_menu_background
    @edit_window.dispose
    @input_window.dispose
  end
  #--------------------------------------------------------------------------
  # ● 원래의 화면에 돌아온다
  #--------------------------------------------------------------------------
  def return_scene
    $scene = Scene_Map.new
  end
  #--------------------------------------------------------------------------
  # ● 프레임 갱신
  #--------------------------------------------------------------------------
  def update
    super
    update_menu_background
    @edit_window.update
    @input_window.update
    if Input.repeat?(Input::B)
      if @edit_window.name == [] && @edit_window.prompt == []
        Sound.play_buzzer
      else
        Sound.play_cancel
        @edit_window.back       
      end
    elsif Input.trigger?(Input::C)
      if @input_window.is_decision          # 커서 위치가 [결정] 의 경우
        if @edit_window.name.size == 0 && @edit_window.prompt.size == 0        # 이름이 비어있는 경우
          @edit_window.restore_default      # 디폴트 이름으로 되돌린다
          if @edit_window.name.size == 0 && @edit_window.prompt.size == 0
            Sound.play_buzzer
          else
            Sound.play_decision
          end
        else
          Sound.play_decision
          name = @edit_window.prompt_to_letter
          name = @edit_window.name.to_s + name
          @actor.name = name   # 액터의 이름을 변경
          return_scene
        end
      elsif @input_window.character != ""   # 문자가 비어있지 않은 경우
        if @edit_window.name.size > @edit_window.max_char
          Sound.play_buzzer
        else
          Sound.play_decision
          @edit_window.add(@input_window.character)       # 문자를 추가         
        end
      end
    end
  end
end
Comment '55'

List of Articles
번호 분류 제목 글쓴이 날짜 조회 수
공지 스크립트 자료 게시물 작성시 주의사항 3 습작 2012.12.24 5398
357 기타 여러스크립트(목적은 포인트) 12 file 인생은 힘들다. 2011.08.26 3087
356 기타 경험치 백분율 계산 2 허걱 2009.06.30 3093
355 기타 Crissaegrim Farm BETA 1.0.0 10 Man... 2008.11.22 3094
354 전투 Animated Battlers VX 3.5 by DerVVulfman 2 Alkaid 2011.11.02 3097
353 장비 KGC 확장 장비 화면 2009/02/15 13 시트르산 2010.09.25 3113
352 전투 Animated Battlers VX 3.4 by DerVVulfman 5 file Alkaid 2010.09.10 3117
351 전투 RPG tankentai에서의 치명적 문제점을 보완한 스크립트 2 file 톰소여동생 2010.11.03 3117
350 커서 애니메이션 12 file RPGbooster 2008.10.11 3127
349 전투 전투후렙업시나오는상세창 11 작은샛별 2010.03.07 3128
348 메뉴 YERD - 시스템 옵션 5 file 훈덕 2009.11.08 3136
347 기타 커스텀 페이지 스크립트 9 file 달표범 2009.09.07 3140
346 스킬 hp소모스킬 31 file DH Games 2010.02.14 3141
345 기타 요리 시스템을 도입하는 스크립트입니다. 9 file 스페나로츠 2011.08.18 3145
344 기타 디스크 체인져 VX!! (업데이트..) 30 file Tofuman 2008.12.02 3168
343 그래픽 KGC_BitmapExtension : 비트맵 클래스 확장 8 file soleone 2010.07.18 3176
342 스킬 발상의전환 : 스킬과 아이템의 공격횟수를 동시에 증가시키기 14 star211 2010.02.16 3179
341 상점 Shopoholic(한글 설명) 11 Man... 2008.10.29 3185
340 상점 상점 할인 스크립트(변수를 이용한 물건 가격 조정) 9 달표범 2009.09.04 3185
339 기타 [자작]게임 실행시 파일 체크 프로그램. 또는 파일 실행기. 16 file NightWind AYARSB 2010.05.20 3193
338 전투 불사신(무적) 스크립트 9 file 미얼 2009.10.29 3198
Board Pagination Prev 1 ... 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 ... 32 Next
/ 32