VX 스크립트

제가 거의 1년전에 올린

아이템 이름 바꾸기 최초 버전이 있었는데요. 혼자서 상당 부분 새로운 기능들을 추가하다가

포맷으로 날려먹고 버려두던 스크립트였습니다 ㅠㅠ

헌데 최근 인기 있는 헤르코스님의 한글 입력 스크립트와 함께 쓰면 안된다는 내용의 쪽지를 좀 받았습니다.

결국 주말을 틈타 함께 사용할 수 있도록 했는데요. 이는 헤르코스님의 허락이 없는 (-_-) 무단도용일 수 도 있습니다.

 

헤르코스님이 불쾌하시다거나 삭제를 원하시면 즉시 삭제 합니다.

 

또한 최소한의 양심으로 헤르코스님의 한글 입력스크립트 없이는 독자적으로 사용 할 수 없는 스크립트입니다.

 

대강 10분만에 한거라 기본테스트는 해보았으나 버그는 있을지도 모릅니다.

#======================================================================================

#2월 28일
#아이템을 소지한게 없을때 공란에서 이름변경 메뉴를 열때 생기던 에러를 수정.
#헤르코스님의 한글 입력 조합과의 함께 사용 가능하도록 수정

#입력방식을 헤르코스님의 한글 입력으로 수정
#한글 입력 조합 스크립트의 하단에 위치해 주세요.
#========================================================================================

module Last_H
  MaxChar = 10   # 아이템 이름의 최대 문자열입니다.  숫자를 수정하시면
                        #글자의최대수가 늘어납니다. 더이상 늘리길 권장하지 않습니다.
                         
end
#==============================================================================
# ■ Scene_Item
#------------------------------------------------------------------------------
# 아이템 화면의 처리를 실시하는 클래스입니다.
#==============================================================================

class Scene_Item < Scene_Base
 
    def update_item_selection
    if Input.trigger?(Input::B)
      Sound.play_cancel
      return_scene
    elsif Input.trigger?(Input::C)
      @item = @item_window.item
      if @item != nil
        $game_party.last_item_id = @item.id
      end
      if $game_party.item_can_use?(@item)
        Sound.play_decision
        determine_item
      else
        Sound.play_buzzer
      end
    elsif Input.trigger?(Input::L)
        Sound.play_decision
        if @item_window.item ==nil
          Sound.play_buzzer
        else
          case @item_window.item
          when RPG::Item
          $game_temp.item_kind = 1
          when RPG::Weapon
          $game_temp.item_kind = 2
          when RPG::Armor
          $game_temp.item_kind =3    
          end
          $game_temp.name_item_id = @item_window.item.id
          $scene = Scene_ItemName.new
        end
    end
  end
 end


 #==============================================================================
# ■ Game_Temp
#------------------------------------------------------------------------------
# 세이브 데이터에 포함되지 않는, 일시적인 데이터를 취급하는 클래스입니다.
# 이 클래스의 인스턴스는 $game_temp 로 참조됩니다.
#==============================================================================

class Game_Temp< Game_Temp
  #--------------------------------------------------------------------------
  # ● 공개 인스턴스 변수
  #--------------------------------------------------------------------------
  attr_accessor :name_item_id              #아이템 이름 입력 id
  attr_accessor :item_kind            #아이템 이름 입력 id
  #--------------------------------------------------------------------------
  # ● 오브젝트 초기화
  #--------------------------------------------------------------------------
  def initialize
     super
    @name_item_id= 0
    @item_kind = 0
  end
end

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

class Scene_ItemName < Scene_Base
 
  #--------------------------------------------------------------------------
  # ● 개시 처리
  #--------------------------------------------------------------------------
  def start
    super
    create_menu_background
    case $game_temp.item_kind
    when 1
    @item = $data_items[$game_temp.name_item_id]
    when 2
    @item = $data_weapons[$game_temp.name_item_id]
    when 3
    @item = $data_armors[$game_temp.name_item_id]
    end
    @edit_window = Window_ItemNameEdit.new(@item, Last_H::MaxChar)
    @input_window = Window_NameInput.new
  end
  #--------------------------------------------------------------------------
  # ● 종료 처리
  #--------------------------------------------------------------------------
  def terminate
    super
    dispose_menu_background
    @edit_window.dispose
    @input_window.dispose
  end
  #--------------------------------------------------------------------------
  # ● 원래의 화면에 돌아온다
  #--------------------------------------------------------------------------
  def return_scene
    $scene = Scene_Item.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
          @item.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


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

class Window_ItemNameEdit < 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(item,max_char)
    super(88, 20, 368, 128)
    @item = item
    @name =item.name
    @prompt = []
    @max_char = max_char
    name_array = item.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
    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

 #==============================================================================
# ■ Scene_File을 재정의
#------------------------------------------------------------------------------
# 저장 파일 화면의 처리를 실시하는 클래스입니다.
#==============================================================================

class Scene_File < Scene_Base
#--------------------------------------------------------------------------
  # ● 세이브 데이터의 기록
  #     file : 쓰기용 파일 오브젝트 (오픈이 끝난 상태)
  #--------------------------------------------------------------------------
  alias last_H_write_save_data write_save_data
  def write_save_data(file)
    last_H_write_save_data(file)
    Marshal.dump($data_items,         file)
    Marshal.dump($data_weapons,         file)
    Marshal.dump($data_armors,         file)
  end
  #--------------------------------------------------------------------------
  # ● 세이브 데이터의 읽기
  #     file : 읽기용 파일 오브젝트 (오픈이 끝난 상태)
  #--------------------------------------------------------------------------
  alias last_H_read_save_data read_save_data
  def read_save_data(file)
    last_H_read_save_data(file)
    $data_items             = Marshal.load(file)
    $data_weapons             = Marshal.load(file)
    $data_armors             = Marshal.load(file)
  end
end

 

 

 

Comment '7'
  • ?
    쉴더 2009.12.20 23:56

    라스트 H님 하요 =-/// 제가 이걸 문의했었는데.. 기억하시려나 ㅎ

  • ?
    쉴더 2009.12.21 00:27

    ㅎㅎ 포맷해서 자료 다날라가고 절망해서 접었는데.. 요새 할게없어서 다시 시작하려고 준비중인데.. 잘안되네요 ㅋ

    vx로 만들까 xp로 만들까 생각중이고 =-///  그나저나 다시하게되면 스크립트 신세좀질께요 ㅎㅎ;

  • ?
    Last H 2009.12.21 00:04

    네 하이요~

    물론 기억하죠. 처음에 만들게 된 계기가 쉴더님이었잖아요 ㅎㅎ

     

  • ?
    탈모군단 2009.12.21 20:00

    제가 말씀드렸더니 금방 수정해주시는군요 ~ ^^

    감사할 따름입니다.

    잘 사용하겠습니다!

  • ?
    카미 2010.01.21 04:53

    잘쓸게요~

  • ?
    미네링 2010.02.25 14:11

    잘쓰겠슴

  • ?
    오리엔탈 2010.07.18 14:25

    ㅋㅋㅋㅋ 10분만에 이걸하시다늬 대단해요~ㅋㅋ


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
» 이름입력 아이템 이름 바꾸기 버전 (헤르코스님의 한글 입력) 7 Last H 2009.12.20 2722
8 이름입력 글자조합 (이름생성용) - 수정 12 file 허걱 2009.07.17 3636
7 이름입력 한글로 이름 입력하는 스크립트입니다. 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