$valh = {}
class Game_Variables
FileVariablesID1 = [699,700]
#--------------------------------------------------------------------------
# ● 初始化
#--------------------------------------------------------------------------
def initialize
@data = []
end
#--------------------------------------------------------------------------
# ● 获取变量
# variable_id : 变量 ID
#--------------------------------------------------------------------------
def [](variable_id)
FileVariablesID1.each do |i|
if variable_id == i
begin
valh = load_data("TempVariables.rxdata")
val = valh
rescue Errno::ENOENT
valh={}
for i in FileVariablesID1.each
valh=0
end
save_data(valh, "TempVariables.rxdata")
retry
end
return val
end
end
if variable_id <= 5000 and @data[variable_id] != nil
return @data[variable_id]
else
return 0
end
end
#--------------------------------------------------------------------------
# ● 设置变量
# variable_id : 变量 ID
# value : 变量的值
#--------------------------------------------------------------------------
def []=(variable_id, value)
if variable_id <= 5000
@data[variable_id] = value
end
$valh = load_data("TempVariables.rxdata") #加这么一句, 先把原来数据读取再在原来基础上储存新数据
n = 0
FileVariablesID1.each do |i|
if variable_id == i
$valh=@data[variable_id]
n+=1
end
end
if n > 0
save_data($valh, "TempVariables.rxdata")
end
end
end