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 타이틀/게임오버 륀느님 요청] 전투 전멸후 Game over없이 특정위치로 이동 10 Last H 2009.02.24 2834
» 스킬 미완성 구버전. 2칸 위에 있는 글을 이용해주세요. 7 Last H 2009.02.23 1925
275 기타 [kcg] 슬립 데미지 상세화 19 BoneheadedAlien 2009.02.22 3242
274 기타 아키루냥님 요청 스크립트(자작) 4 file Last H 2009.02.22 2754
273 영상 동영상 재생 스크립트.-Game_Film II-(테스트) 7 할렘 2009.02.22 3741
272 기타 태양 스크립트. 15 file 할렘 2009.02.20 4463
271 메뉴 CogWheelBars 시스템. 13 file 할렘 2009.02.20 4362
270 메뉴 모그메뉴 스킨입니다. 1 file 아부리 2009.02.16 6866
269 기타 Kylock 밤낮 스크립트 부분 한글화 + 달력 모드 (모드는 자작) 31 file RMdude 2009.02.15 4100
268 HUD 변수 표시 HUD 8 Tofuman 2009.02.15 2469
267 메시지 여러항목 선택지 ... Scene처리.. 23 file 허걱 2009.02.14 5277
266 기타 게임시간&밤낮 54 file 허걱 2009.02.14 6111
265 이동 및 탈것 Wachunga님의 XP용 MapLink VX용으로 개조 6 file 허걱 2009.02.13 3039
264 기타 심플 마우스 시스템 1.5 애드온 11 file RMdude 2009.02.11 4325
263 메뉴 (모그메뉴 풀세트팩 SEL Style.) 유니크급 자료 147 file 할렘 2009.02.07 9558
262 기타 데이터베이스 자체 제한 해체 스크립트 [Database Limit Breaker] 13 file 할렘 2009.02.07 3562
261 메뉴 GuiRPG menu시스템 13 file 할렘 2009.02.07 4849
260 전투 방패가없어? 그럼 방어못하게하는 스크립트. 16 file 할렘 2009.02.07 3425
259 전투 Requiem SBABS (Requiem Squad Based Battle System) 14 vk 2009.02.07 7541
258 기타 라이트 이펙트 스크립트 12 file 아방스 2009.02.07 3262
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