查看: 2227|回复: 2

[已经解决] 求教 拓展存档数量后 怎么让存档首尾相连?

[复制链接]
梦石
0
星屑
7776
在线时间
1525 小时
注册时间
2013-12-3
回帖
303
发表于 2013-12-4 16:58:46 | 显示全部楼层 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有账号?注册会员

×
用的是下面这个脚本,请问怎么改写在移动到最下面后回到存档1?
[pre lang="ruby" line="1"]class Scene_File
SAVEFILE_MAX=25
def initialize(help_text)
@help_text=help_text
end
def main
@help_window=Window_Help.new
@help_window.set_text(@help_text)
@savefile_windows=[]
@cursor_displace=0
for i in 0..3
@savefile_windows.push(Window_SaveFile.new(i,make_filename(i),i))
end
@file_index=0
@savefile_windows[@file_index].selected=true
Graphics.transition
loop do
Graphics.update
Input.update
update
if $scene != self
break
end
end
Graphics.freeze
@help_window.dispose
for i in @savefile_windows
i.dispose
end
end
def update
@help_window.update
for i in @savefile_windows
i.update
end
if Input.trigger?(Input::C)
on_decision(make_filename(@file_index))
$game_temp.last_file_index=@file_index
return
end
if Input.trigger?(Input::B)
on_cancel
return
end
if Input.repeat?(Input::DOWN)
if Input.trigger?(Input::DOWN) or @file_index<SAVEFILE_MAX-1
if @file_index==SAVEFILE_MAX-1
$game_system.se_play($data_system.buzzer_se)
return
end
@cursor_displace+=1
if @cursor_displace==4
@cursor_displace=3
for i in @savefile_windows
i.dispose
end
@savefile_windows=[]
for i in 0..3
f=i-2+@file_index
name= make_filename(f)
@savefile_windows.push(Window_SaveFile.new(f,name,i))
@savefile_windows.selected=false
end
end
$game_system.se_play($data_system.cursor_se)
@file_index=(@file_index+1)
if @file_index==SAVEFILE_MAX
@file_index= SAVEFILE_MAX-1
end
for i in 0..3
@savefile_windows.selected=false
end
@savefile_windows[@cursor_displace].selected=true
return
end
end
if Input.repeat?(Input::UP)
if Input.trigger?(Input::UP) or @file_index>0
if @file_index==0
$game_system.se_play($data_system.buzzer_se)
return
end
@cursor_displace-=1
if @cursor_displace==-1
@cursor_displace=0
for i in @savefile_windows
i.dispose
end
@savefile_windows=[]
for i in 0..3
f=i-1+@file_index
name= make_filename(f)
@savefile_windows.push(Window_SaveFile.new(f,name,i))
@savefile_windows.selected=false
end
end
$game_system.se_play($data_system.cursor_se)
@file_index=(@file_index-1)
if @file_index ==-1
@file_index=0
end
for i in 0..3
@savefile_windows.selected=false
end
@savefile_windows[@cursor_displace].selected=true
return
end
end
end


def make_filename(file_index)
return "Save#{file_index+1}.rxdata"
end
end


class Window_SaveFile<Window_Base
def initialize(file_index,filename,position)
y=64+position*104
super(0,y,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
end[/pre]
梦石
0
星屑
50
在线时间
378 小时
注册时间
2013-10-14
回帖
213
发表于 2013-12-4 17:59:26 | 显示全部楼层
本帖最后由 batfjtn 于 2013-12-4 18:02 编辑

RPG Maker XP v1.03 DK加强v1.00a版(简称DKRM v1.00a)

直接就可以的~!!

你那个脚本看起来太乱了~~!!

是不是你自己自定义的按下按上出了问题~!!

2更:

修改循环的问题修改Window_Selectable~!

附带个DKRM的脚本:

[pre lang="ruby" line="1" file="Window_Selectable"]#==============================================================================
# ■ Window_Selectable
#------------------------------------------------------------------------------
#  拥有光标的移动以及滚动功能的窗口类。
#==============================================================================

class Window_Selectable < Window_Base
  #--------------------------------------------------------------------------
  # ● 定义实例变量
  #--------------------------------------------------------------------------
  attr_reader   :index                    # 光标位置
  attr_reader   :help_window              # 帮助窗口
  #--------------------------------------------------------------------------
  # ● 初始画对像
  #     x      : 窗口的 X 坐标
  #     y      : 窗口的 Y 坐标
  #     width  : 窗口的宽
  #     height : 窗口的高
  #--------------------------------------------------------------------------
  def initialize(x, y, width, height)
    super(x, y, width, height)
    @item_max = 1
    @column_max = 1
    @Index = -1
  end
  #--------------------------------------------------------------------------
  # ● 设置光标的位置
  #     index : 新的光标位置
  #--------------------------------------------------------------------------
  def index=(index)
    @index = index
    # 刷新帮助文本 (update_help 定义了继承目标)
    if self.active and @help_window != nil
      update_help
    end
    # 刷新光标矩形
    update_cursor_rect
  end
  #--------------------------------------------------------------------------
  # ● 获取行数
  #--------------------------------------------------------------------------
  def row_max
    # 由项目数和列数计算出行数
    return (@item_max + @column_max - 1) / @column_max
  end
  #--------------------------------------------------------------------------
  # ● 获取开头行
  #--------------------------------------------------------------------------
  def top_row
    # 将窗口内容的传送源 Y 坐标、1 行的高 32 等分
    return self.oy / 32
  end
  #--------------------------------------------------------------------------
  # ● 设置开头行
  #     row : 显示开头的行
  #--------------------------------------------------------------------------
  def top_row=(row)
    # row 未满 0 的场合更正为 0
    if row < 0
      row = 0
    end
    # row 超过 row_max - 1 的情况下更正为 row_max - 1
    if row > row_max - 1
      row = row_max - 1
    end
    # row 1 行高的 32 倍、窗口内容的传送源 Y 坐标
    self.oy = row * 32
  end
  #--------------------------------------------------------------------------
  # ● 获取 1 页可以显示的行数
  #--------------------------------------------------------------------------
  def page_row_max
    # 窗口的高度,设置画面的高度减去 32 ,除以 1 行的高度 32
    return (self.height - 32) / 32
  end
  #--------------------------------------------------------------------------
  # ● 获取 1 页可以显示的项目数
  #--------------------------------------------------------------------------
  def page_item_max
    # 将行数 page_row_max 乘上列数 @column_max
    return page_row_max * @column_max
  end
  #--------------------------------------------------------------------------
  # ● 帮助窗口的设置
  #     help_window : 新的帮助窗口
  #--------------------------------------------------------------------------
  def help_window=(help_window)
    @help_window = help_window
    # 刷新帮助文本 (update_help 定义了继承目标)
    if self.active and @help_window != nil
      update_help
    end
  end
  #--------------------------------------------------------------------------
  # ● 更新光标举行
  #--------------------------------------------------------------------------
  def update_cursor_rect
    # 光标位置不满 0 的情况下
    if @index < 0
      self.cursor_rect.empty
      return
    end
    # 获取当前的行
    row = @index / @column_max
    # 当前行被显示开头行前面的情况下
    if row < self.top_row
      # 从当前行向开头行滚动
      self.top_row = row
    end
    # 当前行被显示末尾行之后的情况下
    if row > self.top_row + (self.page_row_max - 1)
      # 从当前行向末尾滚动
      self.top_row = row - (self.page_row_max - 1)
    end
    # 计算光标的宽
    cursor_width = self.width / @column_max - 32
    # 计算光标坐标
    x = @index % @column_max * (cursor_width + 32)
    y = @index / @column_max * 32 - self.oy
    # 更新光标矩形
    self.cursor_rect.set(x, y, cursor_width, 32)
  end
  #--------------------------------------------------------------------------
  # ● 刷新画面
  #--------------------------------------------------------------------------
  def update
    super
    # 可以移动光标的情况下
    if self.active and @item_max > 0 and @index >= 0
      # 方向键下被按下的情况下
      if Input.repeat?(Input::DOWN)
        # 列数不是 1 并且方向键的下的按下状态不是重复的情况、
        # 或光标位置在(项目数-列数)之前的情况下
        if (@column_max == 1 and Input.trigger?(Input::DOWN)) or
           @index < @item_max - @column_max
          # 光标向下移动
          $game_system.se_play($data_system.cursor_se)
          @index = (@index + @column_max) % @item_max
        end
      end
      # 方向键上被按下的情况下
      if Input.repeat?(Input::UP)
        # 列数不是 1 并且方向键的下的按下状态不是重复的情况、
        # 或光标位置在列之后的情况下
        if (@column_max == 1 and Input.trigger?(Input::UP)) or
           @index >= @column_max
          # 光标向上移动
          $game_system.se_play($data_system.cursor_se)
          @index = (@index - @column_max + @item_max) % @item_max
        end
      end
      # 方向键右被按下的情况下
      if Input.repeat?(Input::RIGHT)
        # 列数为 2 以上并且、光标位置在(项目数 - 1)之前的情况下
        if @column_max >= 2 and @index < @item_max - 1
          # 光标向右移动
          $game_system.se_play($data_system.cursor_se)
          @index += 1
        end
      end
      # 方向键左被按下的情况下
      if Input.repeat?(Input::LEFT)
        # 列数为 2 以上并且、光标位置在 0 之后的情况下
        if @column_max >= 2 and @index > 0
          # 光标向左移动
          $game_system.se_play($data_system.cursor_se)
          @index -= 1
        end
      end
      # R 键被按下的情况下
      if Input.repeat?(Input::R)
        # 显示的最后行在数据中最后行上方的情况下
        if self.top_row + (self.page_row_max - 1) < (self.row_max - 1)
          # 光标向后移动一页
          $game_system.se_play($data_system.cursor_se)
          @index = [@index + self.page_item_max, @item_max - 1].min
          self.top_row += self.page_row_max
        end
      end
      # L 键被按下的情况下
      if Input.repeat?(Input::L)
        # 显示的开头行在位置 0 之后的情况下
        if self.top_row > 0
          # 光标向前移动一页
          $game_system.se_play($data_system.cursor_se)
          @index = [@index - self.page_item_max, 0].max
          self.top_row -= self.page_row_max
        end
      end
    end
    # 刷新帮助文本 (update_help 定义了继承目标)
    if self.active and @help_window != nil
      update_help
    end
    # 刷新光标矩形
    update_cursor_rect
  end
end
[/pre]

评分

参与人数 1星屑 +90 收起 理由
myownroc + 90 认可答案

查看全部评分

最简单的学习方法就是努力回答别人的问题...
任何教程都没有实践来的重要...
XP小问题都能自己解决了,剩下的就是脚本了...
╰⋛⋋⊱⋋๑角⊱☠c色๑⋌⊰⋌⋚╯
回复

使用道具 举报

梦石
0
星屑
7776
在线时间
1525 小时
注册时间
2013-12-3
回帖
303
 楼主| 发表于 2013-12-4 18:06:53 | 显示全部楼层
batfjtn 发表于 2013-12-4 17:59
RPG Maker XP v1.03 DK加强v1.00a版(简称DKRM v1.00a)

直接就可以的~!!

好的 我去看看0.0
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部