Project1

标题: 求存档上限不限脚本 [打印本页]

作者: 唐马儒1    时间: 2013-11-16 16:43
标题: 求存档上限不限脚本
求脚本←_←………………………………
作者: 美丽晨露    时间: 2013-11-16 18:06
  1. # --------------------------------------------------------------------
  2. class Scene_File
  3.   #——最大存档数量,一般我认为最多50足够了,20比较合适
  4.   SAVEFILE_MAX = 50
  5.   # -------------------
  6.   def initialize(help_text)
  7.     @help_text = help_text
  8.   end
  9.   # -------------------
  10.   def main
  11.     @help_window = Window_Help.new
  12.     @help_window.set_text(@help_text)
  13.     @savefile_windows = []
  14.     @cursor_displace = 0
  15.   #  @menu_com = Sprite.new
  16.   #  @menu_com.bitmap = RPG::Cache.picture("存档.png")
  17.     for i in 0..3
  18.       @savefile_windows.push(Window_SaveFile.new(i, make_filename(i), i))
  19.     end
  20.     @file_index = 0
  21.     @savefile_windows[@file_index].selected = true
  22.     Graphics.transition
  23.     loop do
  24.       Graphics.update
  25.       Input.update
  26.       update
  27.       if $scene != self
  28.         break
  29.       end
  30.     end
  31.     Graphics.freeze
  32. #    @menu_com.bitmap.dispose if @menu_com.bitmap
  33. #    @menu_com.dispose
  34.     @help_window.dispose
  35.     for i in @savefile_windows
  36.       i.dispose
  37.     end
  38.   end
  39.   # -------------------
  40.   def update
  41.     @help_window.update
  42.     for i in @savefile_windows
  43.       i.update
  44.     end
  45.     if Input.trigger?(Input::C)
  46.       on_decision(make_filename(@file_index))
  47.       $game_temp.last_file_index = @file_index
  48.       return
  49.     end
  50.     if Input.trigger?(Input::B)
  51.       on_cancel
  52.       return
  53.     end
  54.     if Input.repeat?(Input::DOWN)
  55.       if Input.trigger?(Input::DOWN) or @file_index < SAVEFILE_MAX - 1
  56.         if @file_index == SAVEFILE_MAX - 1
  57.           $game_system.se_play($data_system.buzzer_se)
  58.           return
  59.         end
  60.         @cursor_displace += 1
  61.         if @cursor_displace == 4
  62.           @cursor_displace = 3
  63.           for i in @savefile_windows
  64.             i.dispose
  65.           end
  66.           @savefile_windows = []
  67.           for i in 0..3
  68.             f = i - 2 + @file_index
  69.             name = make_filename(f)
  70.             @savefile_windows.push(Window_SaveFile.new(f, name, i))
  71.             @savefile_windows[i].selected = false
  72.           end
  73.         end
  74.         $game_system.se_play($data_system.cursor_se)
  75.         @file_index = (@file_index + 1)
  76.         if @file_index == SAVEFILE_MAX
  77.           @file_index = SAVEFILE_MAX - 1
  78.         end
  79.         for i in 0..3
  80.           @savefile_windows[i].selected = false
  81.         end
  82.         @savefile_windows[@cursor_displace].selected = true
  83.         return
  84.       end
  85.     end
  86.     if Input.repeat?(Input::UP)
  87.       if Input.trigger?(Input::UP) or @file_index > 0
  88.         if @file_index == 0
  89.           $game_system.se_play($data_system.buzzer_se)
  90.           return
  91.         end
  92.         @cursor_displace -= 1
  93.         if @cursor_displace == -1
  94.           @cursor_displace = 0
  95.           for i in @savefile_windows
  96.             i.dispose
  97.           end
  98.           @savefile_windows = []
  99.           for i in 0..3
  100.             f = i - 1 + @file_index
  101.             name = make_filename(f)
  102.             @savefile_windows.push(Window_SaveFile.new(f, name, i))
  103.             @savefile_windows[i].selected = false
  104.           end
  105.         end
  106.         $game_system.se_play($data_system.cursor_se)
  107.         @file_index = (@file_index - 1)
  108.         if @file_index == -1
  109.           @file_index = 0
  110.         end
  111.         for i in 0..3
  112.           @savefile_windows[i].selected = false
  113.         end
  114.         @savefile_windows[@cursor_displace].selected = true
  115.         return
  116.       end
  117.     end
  118.   end
  119.   # -------------------
  120.   def make_filename(file_index)
  121.     return "Save#{file_index + 1}.rxdata"
  122.   end
  123.   # -------------------
  124. end
  125. class Window_SaveFile < Window_Base
  126.   # -------------------
  127.   def initialize(file_index, filename, position)
  128.     y = 64 + position * 104
  129.     super(0, y, 640, 104)
  130.     self.contents = Bitmap.new(width - 32, height - 32)
  131.     self.opacity = 0
  132.     @file_index = file_index
  133.     @filename = "Save#{@file_index + 1}.rxdata"
  134.     @time_stamp = Time.at(0)
  135.     @file_exist = FileTest.exist?(@filename)
  136.     if @file_exist
  137.       file = File.open(@filename, "r")
  138.       @time_stamp = file.mtime
  139.       @characters = Marshal.load(file)
  140.       @frame_count = Marshal.load(file)
  141.       @game_system = Marshal.load(file)
  142.       @game_switches = Marshal.load(file)
  143.       @game_variables = Marshal.load(file)
  144.       @total_sec = @frame_count / Graphics.frame_rate
  145.       file.close
  146.     end
  147.     refresh
  148.     @selected = false
  149.   end
  150. end
复制代码
因为这个脚本在主站就能搜索到。
好吧,伸手是不对的,下不为例。

作者: chd114    时间: 2013-11-17 08:50
不推荐···因为存档档位越多游戏运行越卡读档越慢···楼主要做什么游戏要无上限存档档位?




欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1