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 5408
417 상점 상점의 자세한 표시 32 file RPGbooster 2008.10.11 4008
416 온라인 VX Pheonix 2.0 한글 번역 버전 16 미니 2010.04.18 4002
415 2 Players Engine 2인용하기 15 file RPGbooster 2008.10.08 4001
414 파티 파티원이 따라다니는 스크립트 11 file 놀러 2011.09.15 3988
413 아이템 아이템 믹서 21 file 미양 2010.07.02 3983
412 기타 화면 해상도(640 X 480) 스크립트 6 file 쿠쿠밥솥 2012.01.10 3972
411 기타 vx 보안 시스템 19 file 허걱 2009.07.29 3966
410 상점 YERD - 커먼이벤트 샵 12 file 훈덕 2009.11.08 3961
409 메뉴 커서 모양 바꾸는 스크립트 16 아방스 2009.01.20 3959
408 메시지 문장에서1글자마다소리내기 19 작은샛별 2010.03.07 3951
407 이동 및 탈것 vx 걸을때 소리가 나도도록 하는 스크립트 33 아방스 2008.01.31 3947
406 파티 파티 변경 시스템 21 file 아방스 2008.03.09 3945
405 직업 서브클래스 선택 시스템 Subclass Selection System 7 file 카르와푸딩의아틀리에 2009.06.30 3943
404 그래픽 RPG XP의 Transitions효과를 VX에도 적용을 해보자 4 아방스 2008.01.27 3934
403 전투 VX SRPG 스크립트를 수정해봤습니다(8) - 누적수정 30 아이미르 2011.09.09 3916
402 온라인 NETVX 2버전 18 아방스 2009.02.04 3908
401 기타 VX에서 포그 그래픽을 사용하자 16 아방스 2008.01.31 3895
400 메뉴 레벨업 시 자세한 정보 나오는 스크립트 23 아방스 2009.01.20 3895
399 전투 VX]Mog Battleback XP 1.0 11 file WMN 2008.04.06 3869
398 전투 Spirits System 정령 장착?이라고해야되나; 26 file 카르와푸딩의아틀리에 2009.08.19 3869
Board Pagination Prev 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 ... 32 Next
/ 32