Project1
标题:
如何使开关在重新开始游戏时保存当前状态?
[打印本页]
作者:
·雾逝者·
时间:
2014-5-18 07:12
标题:
如何使开关在重新开始游戏时保存当前状态?
RM默认的开关需要在游戏内操作,而重新开始游戏会导致它们被初始化
由于在制作的游戏有特殊的游戏模式,我需要跳过这个初始化
即 “
游戏内开启开关 - 重新开始游戏 - 开关依然为打开状态
” 的效果
求方法
作者:
小凡哥
时间:
2014-5-18 08:41
弄个地图,设定主角的位置在这张地图上,让设置一个事件【自动执行】:打开 开关
作者:
天地有正气
时间:
2014-5-18 10:01
恩……不太理解要求…………但还是写了一些。
# 思路:开启开关的时候写入一个文件,新游戏时读入,然后开启对应的开关。
class Interpreter
#--------------------------------------------------------------------------
# ● 开关操作
#--------------------------------------------------------------------------
def command_121
# 循环全部操作
for i in @parameters[0] .. @parameters[1]
# 更改开关
$game_switches[i] = (@parameters[2] == 0)
file = File.open("Switches.txt","a+")
file.write("\n#{i}")
file.close
end
# 刷新地图
$game_map.need_refresh = true
# 继续
return true
end
end
def switches_on
switches_command_new_game
file = File.open("Switches.txt")
ids = []
file.each_line {|line| ids.push(line)}
for i in 0...ids.size
ids[i].sub!("\n","")
end
ids.delete("")
for i in 0...ids.size
ids[i].to_i
end
for i in 0...ids.size
if $game_switches[i] != nil
$game_switches[i] = true
end
end
file.close
end
复制代码
当使用事件里的“打开开关时”,就会把开关的id保存在一个名为“Switches”的txt文档里。
在需要的时候使用方法"switches_on"就可以读取这些id并打开相应的开关~
作者:
moy
时间:
2014-5-18 10:10
单独将开关信息用
file = File.open(filename, "wb")
Marshal.dump($game_switches, file)
file.close
复制代码
的方式保存在一个名为filename的存档中,并在新游戏时
file = File.open(filename, "wb")
$game_switches = Marshal.load(file)
file.close
复制代码
请务必确定你要这么做,并且需要你先注释第二步,用前一段脚本新建立好一个文档,以免初次运行报错。
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1