设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 2466|回复: 3
打印 上一主题 下一主题

[已经解决] 想做个快速保存的脚本

[复制链接]

Lv3.寻梦者

梦石
0
星屑
1388
在线时间
343 小时
注册时间
2016-7-17
帖子
132
跳转到指定楼层
1
发表于 2020-3-11 22:45:42 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
1星屑
本帖最后由 b200077 于 2020-3-11 22:46 编辑

目前知道怎么在对话匡和大地图呼叫存挡画面,可是翻了翻脚本,我实在看不懂怎么存的,有没有大佬可以讲解一下Datamanager吗?
然后讲解一下要怎么跳过存檔画面存檔

Lv4.逐梦者

梦石
1
星屑
14504
在线时间
2086 小时
注册时间
2017-9-28
帖子
662
2
发表于 2020-3-11 22:45:43 | 只看该作者
  1. # =============================================================================
  2. # TheoAllen - 快速存储和读取
  3. # Version : 1.1
  4. # Contact : www.rpgmakerid.com (or) http://theolized.blogspot.com
  5. # (This script documentation is written in informal indonesian language)
  6. # =============================================================================
  7. ($imported ||= {})[:Theo_Quick] = true
  8. # =============================================================================
  9. # CHANGE LOGS:
  10. # -----------------------------------------------------------------------------
  11. # - 2013.05.11 - Nambahin switch id
  12. # - 2013.05.04 - Script selesai
  13. # =============================================================================
  14. =begin

  15.   介绍:
  16.   该脚本可以让玩家在游戏中按某个键来进行快速存/读档
  17.   存档文件也可以存在指定存档文件下
  18.   
  19.   使用方法:
  20.   插入到插件脚本之下,Main之上
  21.   编辑下面的设置。
  22.   
  23.   使用条款 :
  24.   署名脚本作者, TheoAllen. 你可以自由编辑此脚本,只要你不声明你是脚本的原作者
  25.   如果你想用此脚本于商业游戏,请和我共享收益.别忘了给我一份免费的游戏拷贝.

  26. =end
  27. # =============================================================================
  28. # 设定部分:
  29. # =============================================================================
  30. module THEO
  31.   module SAVE
  32.    
  33.     SAVE_BUTTON = :F5   # 快速存档的按键
  34.     LOAD_BUTTON = :F6   # 快速读档的按键
  35.    
  36.     INDEX = 0 # 快速存/读档时保存到哪个文件(默认为0)
  37.    
  38.     SHOW_COUNT  = 150 # 通知窗口的宽度 (默认:150)
  39.     FADEIN      = 16  # 淡入速度 (默认:16)
  40.     FADEOUT     = 16  # 淡出速度 (默认:16)
  41.    
  42.     SAVE_NOTIFY = "游戏已保存"
  43.     # 显示快速存档时的信息
  44.    
  45.     LOAD_NOTIFY = "游戏已读取"
  46.     # 显示快速读档时的信息
  47.    
  48.     SAVE_SWITCH_ID  = 1
  49.     LOAD_SWITCH_ID  = 1
  50.     # 对应的开关打开时,才会启用快速存/读档功能(*新)
  51.    
  52.   end
  53. end
  54. # =============================================================================
  55. # 设定结束
  56. # =============================================================================
  57. class Window_Notify < Window_Base
  58.   
  59.   def initialize
  60.     super(Graphics.width - window_width, 0, window_width, fitting_height(1))
  61.     self.opacity = 0
  62.     self.contents_opacity = 0
  63.     @show_count = 0
  64.     refresh
  65.   end
  66.   
  67.   def update_fadein
  68.     self.contents_opacity += THEO::SAVE::FADEIN
  69.   end
  70.   
  71.   def update_fadeout
  72.     self.contents_opacity -= THEO::SAVE::FADEOUT
  73.   end
  74.   
  75.   def refresh
  76.     contents.clear
  77.     draw_background(contents.rect)
  78.     draw_text(0,0,contents.width,contents.height,@notify,1)
  79.   end
  80.   
  81.   def show=(text)
  82.     @notify = text
  83.     open
  84.   end
  85.   
  86.   def window_width
  87.     return 240
  88.   end
  89.   
  90.   def update
  91.     super
  92.     if @show_count > 0
  93.       update_fadein
  94.       @show_count -= 1
  95.     else
  96.       update_fadeout
  97.     end
  98.   end
  99.   
  100.   def open
  101.     refresh
  102.     @show_count = THEO::SAVE::SHOW_COUNT
  103.     self.contents_opacity = 0
  104.     self
  105.   end
  106.   
  107.   def close
  108.     @show_count = 0
  109.     self
  110.   end
  111.   
  112.   def draw_background(rect)
  113.     temp_rect = rect.clone
  114.     temp_rect.width /= 2
  115.     contents.gradient_fill_rect(temp_rect, back_color2, back_color1)
  116.     temp_rect.x = temp_rect.width
  117.     contents.gradient_fill_rect(temp_rect, back_color1, back_color2)
  118.   end
  119.   
  120.   def back_color1
  121.     Color.new(0, 0, 0, 192)
  122.   end
  123.   
  124.   def back_color2
  125.     Color.new(0, 0, 0, 0)
  126.   end
  127. end
  128.   

  129. class Scene_Map < Scene_Base
  130.   
  131.   alias start_quick_save_load start
  132.   def start
  133.     start_quick_save_load
  134.     create_notify
  135.     show_load_notify if $game_system.quick_load
  136.   end
  137.   
  138.   def create_notify
  139.     @notify_window = Window_Notify.new
  140.     @notify_window.viewport = @viewport
  141.   end
  142.   
  143.   alias quick_save_load_update update
  144.   def update
  145.     quick_save_load_update
  146.     save_file if input_save?
  147.     load_file if input_load?
  148.   end
  149.   
  150.   def save_file
  151.     @notify_window.close
  152.     $game_system.on_before_save
  153.     DataManager.save_game(THEO::SAVE::INDEX)
  154.     show_save_notify
  155.   end
  156.   
  157.   def load_file
  158.     @notify_window.close
  159.     DataManager.load_game(THEO::SAVE::INDEX)
  160.     $game_system.on_after_load
  161.     SceneManager.goto(Scene_Map)
  162.     $game_system.quick_load = true
  163.   end
  164.   
  165.   def show_save_notify
  166.     @notify_window.show = THEO::SAVE::SAVE_NOTIFY
  167.   end
  168.   
  169.   def show_load_notify
  170.     @notify_window.show = THEO::SAVE::LOAD_NOTIFY
  171.     $game_system.quick_load = false
  172.   end
  173.   
  174.   def input_save?
  175.     id = THEO::SAVE::SAVE_SWITCH_ID
  176.     Input.trigger?(THEO::SAVE::SAVE_BUTTON) && (id > 0 ? $game_switches[id] : true)
  177.   end
  178.   
  179.   def input_load?
  180.     id = THEO::SAVE::LOAD_SWITCH_ID
  181.     Input.trigger?(THEO::SAVE::LOAD_BUTTON) && (id > 0 ? $game_switches[id] : true)
  182.   end
  183.   
  184. end

  185. class Game_System
  186.   attr_accessor :quick_load
  187.   
  188.   alias pre_quick_init initialize
  189.   def initialize
  190.     pre_quick_init
  191.     @quick_load = false
  192.   end
  193.   
  194. end
复制代码

点评

这个在沒存档时快速读档的话,会報錯...  发表于 2020-3-26 11:52
VA外站脚本汉化群:226308173   |    部分远古文件备份:https://wwzv.lanzoue.com/b02rac5pc  密码:acgm
回复

使用道具 举报

Lv4.逐梦者

梦石
2
星屑
6639
在线时间
501 小时
注册时间
2018-3-23
帖子
533

R考场第七期银奖

3
发表于 2020-3-12 10:05:05 | 只看该作者
本帖最后由 MCCF 于 2020-3-12 10:09 编辑

如果LZ是自己在尝试的话……我觉得善用脚本编辑器的“全局搜索”吧,可以很方便地找到需要查看的方法。

存档的基本方法是DataManager.save_game(index),index是存档编号。
内部实现很简单,把当前$game_variables和$game_player这些游戏实例用Marshal.dump塞进存档。然后外面再包装一个异常处理,防止无法写入导致脚本崩溃。

读档是DataManager.load_game(index)。就是把当前的游戏实例设置成存档中所存储的。
以前写过一个自动存档脚本,这种脚本的套路是,点击后不进入Scene_Save,直接操作DataManager存档。读档也一样。

另外,如果要调整存档的内容的话,VA也提供了方法。比如:
RUBY 代码复制
  1. class << DataManager
  2.   #--------------------------------------------------------------------------
  3.   # ● 生成存档内容
  4.   #--------------------------------------------------------------------------
  5.   alias orig_make_save_contents make_save_contents
  6.   def make_save_contents
  7.     orig_make_save_contents
  8.     contents[:something] = $game_something
  9.   end
  10.   #--------------------------------------------------------------------------
  11.   # ● 展开存档内容
  12.   #--------------------------------------------------------------------------
  13.   alias orig_extract_save_contents extract_save_contents
  14.   def extract_save_contents(contents)
  15.     orig_extract_save_contents(contents)
  16.     $game_something = contents[:something]
  17.   end
  18. end

这两个方法用于生成和获取存档的具体内容(contents)。

评分

参与人数 1+1 收起 理由
b200077 + 1 我很赞同

查看全部评分

祝好。
回复

使用道具 举报

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

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-4-30 10:37

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表