질문과 답변

Extra Form

셀프변수스크립트를넣고 세이브하려니까  충돌뜨네요 고칠수있는방법좀요..


#=============================================================================
# ** SG Self Variables B
#=============================================================================
# sandgolem
# Version 1
# 19.04.06
#=============================================================================
#
# To use this script, use variables #1 - 3 in any events.
# It'll be whatever that event's self variable for it is.
# This also works for event page conditions
# In battle, these are temporary variables that is reset with each.
#
#=============================================================================
#
# To check for updates or find more scripts, visit:
#      http://www.gamebaker.com/rmxp/scripts/
#
# To use this script, copy it and insert it in a new section above "Main",
# but under the default scripts. Needs to be under SG Script Control, but
# above any that alias Game_Event's refresh.
#
# Have problems? You can leave me a message at:
# http://www.gamebaker.com/users/sandgolem
#
#=============================================================================

class Scene_Title
  alias sandgolem_selfvarb_title_main main
  def main
    $sg_self_variables = {}
    sandgolem_selfvarb_title_main
  end
end   

class Scene_Save < Scene_File   
  alias sandgolem_selfvarb_save_write write_save_data
  def write_save_data(file)
    $game_sg['selfvars'] = $sg_self_variables
    sandgolem_selfvarb_save_write(file) 
    $game_sg['selfvars'] = nil
  end
end

class Scene_Load < Scene_File     
  alias sandgolem_selfvarb_load_read read_save_data
  def read_save_data(file) 
    sandgolem_selfvarb_load_read(file)
    if $game_sg['selfvars'] != nil
      $sg_self_variables = $game_sg['selfvars']
      $game_sg['selfvars'] = nil
    end   
  end
end

class Scene_Battle
  alias sandgolem_selfvarb_battle_main main
  def main
    for i in 1 .. 3
      $game_variables[i] = 0
    end
    sandgolem_selfvarb_battle_main
  end
end

class Interpreter
  alias sandgolem_selfvarb_interp_execcommand execute_command
  def execute_command
    if $scene.is_a?(Scene_Map)
      for i in 1 .. 3
        key = [@map_id, @event_id, i]
        if $sg_self_variables[key] != nil
          $game_variables[i] = $sg_self_variables[key]
        else
          $game_variables[i] = 0
        end
      end
    end
    sandgolem_selfvarb_interp_execcommand
  end
 
  alias sandgolem_selfvarb_interp_command122 command_122
  def command_122
    sandgolem_selfvarb_interp_command122
    if @parameters[0] <= 3 && $scene.is_a?(Scene_Map)
      for i in @parameters[0] .. @parameters[1]
        if i <= 3
          key = [@map_id, @event_id, i]
          $sg_self_variables[key] = $game_variables[i]
        end
      end
      $game_map.need_refresh = true
    end
  end
end

class Game_Event < Game_Character
 
  def refresh
    new_page = nil
    unless @erased
      for page in @event.pages.reverse
        c = page.condition
        if c.switch1_valid
          if $game_switches[c.switch1_id] == false
            next
          end
        end
        if c.switch2_valid
          if $game_switches[c.switch2_id] == false
            next
          end
        end
#------------------------------------------------------------------------------
# Begin SG Self Variables edit
#------------------------------------------------------------------------------
        if c.variable_valid
          if c.variable_id <= 3
            key = [$game_map.map_id, @event.id, c.variable_id]
            if $sg_self_variables[key] != nil
              if $sg_self_variables[key] < c.variable_value
                next
              end
            else
              next
            end
          elsif $game_variables[c.variable_id] < c.variable_value
            next
          end
        end
#------------------------------------------------------------------------------
# End SG Self Variables edit
#------------------------------------------------------------------------------
        if c.self_switch_valid
          key = [@map_id, @event.id, c.self_switch_ch]
          if $game_self_switches[key] != true
            next
          end
        end
        new_page = page
        break
      end
    end
    if new_page == @page
      return
    end
    @page = new_page
    clear_starting
    if @page == nil
      @tile_id = 0
      @character_name = ""
      @character_hue = 0
      @move_type = 0
      @through = true
      @trigger = nil
      @list = nil
      @interpreter = nil
      return
    end
    @tile_id = @page.graphic.tile_id
    @character_name = @page.graphic.character_name
    @character_hue = @page.graphic.character_hue
    if @original_direction != @page.graphic.direction
      @direction = @page.graphic.direction
      @original_direction = @direction
      @prelock_direction = 0
    end
    if @original_pattern != @page.graphic.pattern
      @pattern = @page.graphic.pattern
      @original_pattern = @pattern
    end
    @opacity = @page.graphic.opacity
    @blend_type = @page.graphic.blend_type
    @move_type = @page.move_type
    @move_speed = @page.move_speed
    @move_frequency = @page.move_frequency
    @move_route = @page.move_route
    @move_route_index = 0
    @move_route_forcing = false
    @walk_anime = @page.walk_anime
    @step_anime = @page.step_anime
    @direction_fix = @page.direction_fix
    @through = @page.through
    @always_on_top = @page.always_on_top
    @trigger = @page.trigger
    @list = @page.list
    @interpreter = nil
    if @trigger == 4
      @interpreter = Interpreter.new
    end
    check_event_trigger_auto
  end
end


---------------------------------여기까지 셀프변수 스크립트


  #--------------------------------------------------------------------------
  # ● 공개 인스턴스 변수
  #--------------------------------------------------------------------------
  attr_reader   :filename                 # 파일명
  attr_reader   :selected                 # 선택 상태
  #--------------------------------------------------------------------------
  # ● 오브젝트 초기화
  #     file_index : 세이브 파일의 인덱스 (0~3)
  #     filename   : 파일명
  #--------------------------------------------------------------------------
  def initialize(file_index, filename)
    super(0, 64 + file_index % 4 * 104, 640, 104)
    self.contents = Bitmap.new(width - 32, height - 32)
    @file_index = file_index
    @filename = "Save#{@file_index + 1}.rxdata"
    @time_stamp = Time.at(0)
    @file_exist = FileTest.exist?(@filename)
    if @file_exist
      file = File.open(@filename, "r")
      @time_stamp = file.mtime
      @characters = Marshal.load(file)
      @frame_count = Marshal.load(file)
      @game_system = Marshal.load(file)
      @game_switches = Marshal.load(file)
      @game_variables = Marshal.load(file)
      @total_sec = @frame_count / Graphics.frame_rate
      file.close
    end
    refresh
    @selected = false
  end
  #--------------------------------------------------------------------------
  # ● 리프레쉬
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    # 파일 번호를 묘화
    self.contents.font.color = normal_color
    name = "파일 #{@file_index + 1}"
    self.contents.draw_text(4, 0, 600, 32, name)
    @name_width = contents.text_size(name).width
    # 세이브 파일이 존재하는 경우
    if @file_exist
      # 캐릭터를 묘화
      for i in 0...@characters.size
        bitmap = RPG::Cache.character(@characters[i][0], @characters[i][1])
        cw = bitmap.rect.width / 4
        ch = bitmap.rect.height / 4
        src_rect = Rect.new(0, 0, cw, ch)
        x = 300 - @characters.size * 32 + i * 64 - cw / 2
        self.contents.blt(x, 68 - ch, bitmap, src_rect)
      end
      # 플레이 시간을 묘화
      hour = @total_sec / 60 / 60
      min = @total_sec / 60 % 60
      sec = @total_sec % 60
      time_string = sprintf("%02d:%02d:%02d", hour, min, sec)
      self.contents.font.color = normal_color
      self.contents.draw_text(4, 8, 600, 32, time_string, 2)
      # 타임 스탬프를 묘화
      self.contents.font.color = normal_color
      time_string = @time_stamp.strftime("%Y/%m/%d %H:%M")
      self.contents.draw_text(4, 40, 600, 32, time_string, 2)
    end
  end
  #--------------------------------------------------------------------------
  # ● 선택 상태의 설정
  #     selected : 새로운 선택 상태 (true=선택 false=비선택)
  #--------------------------------------------------------------------------
  def selected=(selected)
    @selected = selected
    update_cursor_rect
  end
  #--------------------------------------------------------------------------
  # ● 커서의 구형 갱신
  #--------------------------------------------------------------------------
  def update_cursor_rect
    if @selected
      self.cursor_rect.set(0, 0, @name_width + 8, 32)
    else
      self.cursor_rect.empty
    end
  end
end


----------------------------------여기까지 세이브스크립트


도와주세요...


List of Articles
종류 분류 제목 글쓴이 날짜 조회 수
공지 묻고 답하기 가이드 습작 2014.06.14 12388
RMXP 두스크립트가 충돌뜨는데 무마할수있는방법없나요 Haze~ 2014.04.19 415
RMXP 문여닫는방법 3 file 안녕포럽아 2014.04.18 659
RMXP 캐릭터사라지게하는법 5 file 안녕포럽아 2014.04.18 601
RMXP 세이브파일1을 로드하기 3 humuri 2014.04.12 657
RMXP 이동 경로 설정을 이용하지 않고 이벤트의 속도 변경하기 googoo 2014.04.06 729
RMXP 스크립트 수정하고 싶은데 도와주세요. 1 아미상 2014.04.05 610
RMXP 대화창의 길이를 늘리고 싶은데, 어떻게 하나요? 1 슈트롱 2014.04.02 565
RMXP 한 맵에 2개의 맵칩을 사용할수는없나여?? 1 떠오르는게없다 2014.03.31 746
RMXP rpg xp 동영상 찍는법 흙흙흙 2014.03.31 706
RMXP 턴알 주인공 기절시 게임오버 시키는법 3 흙흙흙 2014.03.26 772
RMXP 보행수 표기 스크립트 삭제후 문제가 발생했습니다. 2 file 나나니벌 2014.03.22 818
RMXP 아오오니처럼 몬스터가 랜덤으로 나오게 하는 방법좀 알려주세요 ㅠㅠ 3 고수의길 2014.03.20 887
RMXP 변수에 아이템 ID를 대입하는 법 있나요? 모르모트 2014.03.20 607
RMXP 영어 인디 rpg 'Gingiva'게임 속 텍스트가 출력되지 않습니다. 5 luke26 2014.03.19 1224
RMXP 아이템으로 돈 얻기 10 type_0 2014.03.08 546
RMXP 변수에 대한 오류 8 file 윌리스 2014.03.06 717
RMXP 이벤트가 맨 앞에, 맵타일이 그 뒤에, 주인공이 맨 뒤에 오게 할 수 있나요? 2 file S5S5 2014.03.06 835
RMXP MP를 화면 오른쪽아래에 표시하고싶습니다^^ 4 바흐 2014.03.05 739
RMXP 이벤트의 일시삭제의 기능이 뭔가요 3 bluesu1004 2014.03.05 771
RMXP 자동실행,병렬처리 4 bluesu1004 2014.03.05 1322
Board Pagination Prev 1 ... 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 ... 90 Next
/ 90