VX 스크립트

액터의 이름입력 처럼 아이템의 이름 입력을 처리하는 스크립트 입니다.
아직 문제가 좀있는 스크립트이긴 합니다만 일단 올려 보겠습니다.

사용법은 간단히 아이템메뉴창에서 아이템위에서 키보드 Q키를 누르면 입력테이블이 뜨고
아이템 이름을 자유롭게 지정할 수 있습니다. (입력테이블에 있는 글자한도 내에)
일단 초기작이기 때문에 진짜 '아이템' 만 됩니다. 장비류에서 Q키를 입력하게 되면 엉뚱한
아이템 이름이 뜨고 그게 수정되어버리죠. 즉 선택된 무기나 방어구의 id와 같은 id의 아이템이 수정되는 거죠.
또한 결정적으로 저장한후 로드 할시 아이템 이름은 초기화 됩니다 -_-;

장비류의 경우는 판단해서 분기만 해주면 어찌어찌 될 것 같긴한데 저장로드 부분은 오리무중입니다...
아래 부터  복사해주세요.
========================================================================================

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
      $game_temp.name_item_id = @item_window.item.id
      $scene = Scene_ItemName.new
    end
  end
 end


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

class Game_Temp
  #--------------------------------------------------------------------------
  # ● 공개 인스턴스 변수
  #--------------------------------------------------------------------------
  attr_accessor :next_scene               # 변환 대기중의 화면 (문자열)
  attr_accessor :map_bgm                  # 맵 화면 BGM (전투시 기억용)
  attr_accessor :map_bgs                  # 맵 화면 BGS (전투시 기억용)
  attr_accessor :common_event_id          # 커먼 이벤트 ID
  attr_accessor :in_battle                # 전투중 플래그
  attr_accessor :battle_proc              # 전투 콜백 (Proc)
  attr_accessor :shop_goods               # 상점 상품 리스트
  attr_accessor :shop_purchase_only       # 상점 구입만 플래그
  attr_accessor :name_actor_id            # 이름 입력 액터 ID
  attr_accessor :name_max_char            # 이름 입력 최대 문자수
  attr_accessor :menu_beep                # 메뉴 SE 연주 플래그
  attr_accessor :last_file_index          # 마지막에 세이브한 파일의 번호
  attr_accessor :debug_top_row            # 디버그 화면 상태 보존용
  attr_accessor :debug_index              # 디버그 화면 상태 보존용
  attr_accessor :background_bitmap        # 배경 비트 맵
  attr_accessor :name_item_id              #아이템 이름 입력 id
  #--------------------------------------------------------------------------
  # ● 오브젝트 초기화
  #--------------------------------------------------------------------------
  def initialize
    @next_scene = nil
    @map_bgm = nil
    @map_bgs = nil
    @common_event_id = 0
    @in_battle = false
    @battle_proc = nil
    @shop_goods = nil
    @shop_purchase_only = false
    @name_actor_id = 0
    @name_max_char = 0
    @menu_beep = false
    @last_file_index = 0
    @debug_top_row = 0
    @debug_index = 0
    @background_bitmap = Bitmap.new(1, 1)
    @name_item_id=0
  end
end

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

class Scene_ItemName < Scene_Base
  #--------------------------------------------------------------------------
  # ● 개시 처리
  #--------------------------------------------------------------------------
  def start
    super
    create_menu_background
    @item = $data_items[$game_temp.name_item_id]
    @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.index > 0             # 문자 위치가 좌단은 아니다
        Sound.play_cancel
        @edit_window.back
      end
    elsif Input.trigger?(Input::C)
      if @input_window.is_decision          # 커서 위치가 [결정] 의 경우
        if @edit_window.name == ""          # 이름이 비어있는 경우
          @edit_window.restore_default      # 디폴트 이름으로 되돌린다
          if @edit_window.name == ""
            Sound.play_buzzer
          else
            Sound.play_decision
          end
        else
          Sound.play_decision
          @item.name = @edit_window.name   # 아이템의 이름을 변경
          return_scene
        end
      elsif @input_window.character != ""   # 문자가 비어있지 않은 경우
        if @edit_window.index == @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
  #--------------------------------------------------------------------------
  # ● 공개 인스턴스 변수
  #--------------------------------------------------------------------------
  attr_reader   :name                     # 이름
  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
    @max_char = max_char
    name_array = @name.split(//)[0...@max_char]   # 최대 문자수에 거둔다
    @name = ""
    for i in 0...name_array.size
      @name += name_array[i]
    end
    @default_name = @name
    @index = name_array.size
    self.active = false
    refresh
    update_cursor
  end
  #--------------------------------------------------------------------------
  # ● 디폴트의 이름에 되돌린다
  #--------------------------------------------------------------------------
  def restore_default
    @name = @default_name
    @index = @name.split(//).size
    refresh
    update_cursor
  end
  #--------------------------------------------------------------------------
  # ● 문자의 추가
  #     character : 추가하는 문자
  #--------------------------------------------------------------------------
  def add(character)
    if @index < @max_char and character != ""
      @name += character
      @index += 1
      refresh
      update_cursor
    end
  end
  #--------------------------------------------------------------------------
  # ● 문자의 삭제
  #--------------------------------------------------------------------------
  def back
    if @index > 0
      name_array = @name.split(//)          # 한 자 삭제
      @name = ""
      for i in 0...name_array.size-1
        @name += name_array[i]
      end
      @index -= 1
      refresh
      update_cursor
    end
  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_array = @name.split(//)
    for i in 0...@max_char
      c = name_array[i]
      c = '_' if c == nil
      self.contents.draw_text(item_rect(i), c, 1)
    end
  end
  #--------------------------------------------------------------------------
  # ● 커서의 갱신
  #--------------------------------------------------------------------------
  def update_cursor
    self.cursor_rect = item_rect(@index)
  end
  #--------------------------------------------------------------------------
  # ● 프레임 갱신
  #--------------------------------------------------------------------------
  def update
    super
    update_cursor
  end
end

 

 

Comment '7'
  • ?
    zx5024 2009.02.24 14:33
    와우 좋긴좋은데 오류가 좀있어서 ㅎㅎㅎ!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    제대로 완성해서 올려주시면 바로 쓸 의사가있음
  • ?
    Last H 2009.02.24 17:00
    아아... 이건 솔직히 하다말고 올린거라...=_=;
    시간 좀 있으면 어떻게든 될 꺼 같은데 이 놈의 게으름은...
  • ?
    쉴더 2009.02.24 19:32
    오오... 제가 일이 조금 있어서 지금 들어왔습니다만.
    라스트님 감사합니다 ㅠ=!!
    완벽판은 아니지만, 제가 어찌어찌 공부라도 해보고 수정해볼게요!
    감사합니다 !!
  • ?
    Last H 2009.02.25 20:48
    나름의 완벽판 만들어서 새로 올렸습니다 ^^
    테스트 플레이 해본 결과 제가 발견한 버그는 없었습니다.
  • ?
    독한 2009.02.25 00:12
    허억.. 이 스크립트 Game XP에서 쓸수있으면 좋겠 ㄷㄷ..
  • ?
    VAAVA123 2009.04.11 20:20
    제가 초보자인데 어떻게 사용함?..
  • ?
    Last H 2009.04.12 00:25
    이거 말고 바로 윗윗글에 제대로된거 있어요 그거로 사용하세요.

List of Articles
번호 분류 제목 글쓴이 날짜 조회 수
공지 스크립트 자료 게시물 작성시 주의사항 3 습작 2012.12.24 5398
» 스킬 미완성 구버전. 2칸 위에 있는 글을 이용해주세요. 7 Last H 2009.02.23 1925
96 기타 Etude87_GAGA_Chat 4 습작 2012.06.14 1916
95 전투 GTBS for 2d_iso_x3 by Clarabel 2 습작 2013.05.13 1879
94 기타 장애물을 피하고 다가오게 하는 스크립트 5 file 박력남 2014.02.25 1877
93 파티 파티원의 첫번째 멤버로 추가하기 5 허걱 2012.12.04 1865
92 장비 Equipment Set Bonus 6 Man... 2008.10.25 1849
91 타이틀/게임오버 New Title Screen 3 Man... 2008.10.28 1832
90 ES Character Info 6 file RPGbooster 2008.10.08 1824
89 기타 KGC counter 스크립트. 반격기 추가스크립트입니다. 4 우켈킁 2011.03.31 1812
88 제작도구 Windowskin generator VX by Aindra and Woratana 1 file Alkaid 2010.09.18 1791
87 Limit Break VX 3 Man... 2008.10.28 1777
86 메시지 Etude87_Item_Choice ver.1.00 file 습작 2013.02.16 1771
85 스킬 SW_BookSkill && EchantScroll(상호충돌수정버전) 6 시옷전사 2011.08.22 1758
84 기타 배틀신에서 곡 넘기기 2 rukan 2009.07.02 1757
83 Repel Effect 1 Man... 2008.10.28 1753
82 엄청 좋음(DEMO)클릭 하이퍼링크 걸려있음(누가 변혁좀 해 줬으면...) 4 Man... 2008.10.27 1745
81 기타 Wora's Christmas Giftbox 2008 4 file Alkaid 2010.09.18 1744
80 Direction Movement Style 4 Man... 2008.10.28 1719
79 이동 및 탈것 이동 기능 파워업 (장애물 등을 피하는 이동방식) 8 file 파노 2014.04.27 1716
78 타이틀/게임오버 코아 코스튬씨의 랜덤 타이틀 스크립트를 VX용으로 변환 2 Alkaid 2012.09.14 1701
Board Pagination Prev 1 ... 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 Next
/ 32