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
277 기타 [요청자료] 유즈미짱 님께서 요청한 그림표시 입니다. 5 file 허걱 2009.07.08 2976
276 메시지 [완성]RPG Maker VX용 한글 조사 자동결정 10 file 시릴캣 2009.08.13 4598
275 장비 [스크립트]무기에 옵션을 부가하자 18 아방이 2008.01.29 5380
274 변수/스위치 [무한응용가능]스위치/변수 저장/로딩 스크립트 7 카리스 2010.03.31 2854
273 전투 [덮어씌우기]Window_ActorCommand_EX 4 맛난호빵 2011.03.12 2341
272 기타 [XP / VX 공용] rand() 함수 확장 스크립트 4 허걱 2011.09.13 2362
271 직업 [VX] Blue Mage by Fomar0153 9 WMN 2008.04.06 2785
270 전투 [vx] ATB 시스템. 10 만들어보자꾸나 2008.07.05 4925
269 기타 [VX] Anti-Lag 1.2c by Anaryu[예제첨부] 3 file WMN 2008.04.06 2371
268 스킬 [ultimate series]스킬,아이템 데미지계산식을 자기입맛에 맞게 고치는 스크립트 16 file EuclidE 2010.05.04 4373
267 이름입력 [rpg vx]한글 스크립트(저번 것보단 업그레이드 된 것입니다.^^) 17 file 레시온 2008.03.28 4736
266 전투 [RPG VX]기술에 쿨타임을 부여하는 스크립트 3 스리아씨 2013.12.05 2348
265 스킬 [RPG VX] 턴알 스킬 쿨타임 스크립트! (잘돌아감) 5 듀란테 2015.08.18 1671
264 타이틀/게임오버 [NO.0 간단 스크립트] 타이틀에 제작자 정보 올려보기 14 file NO.0 2011.01.30 3362
263 기타 [KGC]한계돌파 9 방콕족의생활 2008.06.13 3599
262 기타 [kcg] 슬립 데미지 상세화 19 BoneheadedAlien 2009.02.22 3242
261 HUD Zelda Health System 11 file 비극ㆍ 2010.04.18 2850
260 스킬 YERD - 커스텀 스킬 이펙트 13 file 훈덕 2009.11.08 4080
259 상점 YERD - 커먼이벤트 샵 12 file 훈덕 2009.11.08 3961
258 메뉴 YERD - 커먼 이벤트 메뉴 4 file 훈덕 2009.11.08 3849
Board Pagination Prev 1 ... 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 ... 32 Next
/ 32