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
11 이름입력 Etude87_HG_Hangul_Name_Scene file 습작 2012.06.14 1948
10 이름입력 아이템, 장비, 스킬 이름 색깔 바꾸기 14 까까까 2011.03.04 3732
9 이름입력 아이템 이름 바꾸기 버전 (헤르코스님의 한글 입력) 7 Last H 2009.12.20 2722
8 이름입력 글자조합 (이름생성용) - 수정 12 file 허걱 2009.07.17 3636
» 이름입력 한글로 이름 입력하는 스크립트입니다. 55 file 헤르코스 2009.03.18 6662
6 이름입력 아이템 이름을 내마음대로 정하자! name_changer 1.0v 26 file Last H 2009.02.25 4067
5 이름입력 주인공이름으로 저장하는 스크립트 6 file 아방스 2009.02.07 4079
4 이름입력 모그 이름 바꾸기 한글 변역! 2 Man.... 2008.11.04 4114
3 이름입력 MOG 이름바꾸기 11 file RPGbooster 2008.10.08 3285
2 이름입력 [rpg vx]한글 스크립트(저번 것보단 업그레이드 된 것입니다.^^) 17 file 레시온 2008.03.28 4736
1 이름입력 한글 이름 입력 스크립트입니다.^^ 14 레시온 2008.03.18 4382
Board Pagination Prev 1 Next
/ 1