Project1
标题: 怎么用代码直接控制存入读取某个档位 [打印本页]
作者: 真_真空    时间: 2017-1-18 20:11
标题: 怎么用代码直接控制存入读取某个档位
 本帖最后由 真_真空 于 2017-1-18 20:18 编辑 
知道是个老问题了= =!
图书馆里的这个
- class Scene_Save 
-   def autosave 
-     # 存档写在 1 号位上,如果写在其他位置要改变这个文件名。 
-     filename = "Save1.rxdata" 
-     file = File.open(filename, "wb") 
-     write_save_data(file) 
-     file.close 
-   end 
- end 
- class Scene_Save 
 
-   def autosave 
 
-     # 存档写在 1 号位上,如果写在其他位置要改变这个文件名。 
 
-     filename = "Save1.rxdata" 
 
-     file = File.open(filename, "wb") 
 
-     write_save_data(file) 
 
-     file.close 
 
-   end 
 
- end 
 
- save = Scene_Save.new 
- save.autosave 
- save = Scene_Save.new 
 
- save.autosave 
 
插入后,运行就直接报错(新工程实验)
 
这个要怎么解决?
或者有没有同样简洁的存读档代码?
比如不需要插入到main前,可以事件直接调用的?
作者: RyanBern    时间: 2017-1-18 20:16
 本帖最后由 RyanBern 于 2017-1-18 20:25 编辑 
用法不对。
请将第一段脚本插入 main 前。
然后第二段脚本则是在事件中直接调用。
我这边测试没有有问题。
 Project12.7z
(907.61 KB, 下载次数: 37)
Project12.7z
(907.61 KB, 下载次数: 37)
作者: 真_真空    时间: 2017-1-18 20:43
原因是一个十分……神奇的问题,点代码框的右上角复制没用问题
然而我是直接全选了代码右键复制的,然后就会报错
对比了半天后发现
把每行代码前的空格删除后,就没问题了
难道直接复制会复制到什么看不见的字符什么的嘛= =
作者: RyanBern    时间: 2017-1-18 21:35
用法一样。第一段插在 Main 前,实际使用调用第二段
- class Scene_Load 
-   def autoload 
-     filename = 'Save1.rxdata' 
-     unless FileTest.exist?(filename) 
-       return 
-     end 
-     # Read save data 
-     file = File.open(filename, "rb") 
-     read_save_data(file) 
-     file.close 
-     # Restore BGM and BGS 
-     $game_system.bgm_play($game_system.playing_bgm) 
-     $game_system.bgs_play($game_system.playing_bgs) 
-     # Update map (run parallel process event) 
-     $game_map.update 
-     # Switch to map screen 
-     $scene = Scene_Map.new 
-   end 
- end 
- class Scene_Load 
 
-   def autoload 
 
-     filename = 'Save1.rxdata' 
 
-     unless FileTest.exist?(filename) 
 
-       return 
 
-     end 
 
-     # Read save data 
 
-     file = File.open(filename, "rb") 
 
-     read_save_data(file) 
 
-     file.close 
 
-     # Restore BGM and BGS 
 
-     $game_system.bgm_play($game_system.playing_bgm) 
 
-     $game_system.bgs_play($game_system.playing_bgs) 
 
-     # Update map (run parallel process event) 
 
-     $game_map.update 
 
-     # Switch to map screen 
 
-     $scene = Scene_Map.new 
 
-   end 
 
- end 
 
- load = Scene_Load.new 
- load.autoload 
- load = Scene_Load.new 
 
- load.autoload 
 
| 欢迎光临 Project1 (https://rpg.blue/) | Powered by Discuz! X3.1 |