#==============================================================================
class Game_Switches
# 需要保存的开关ID。
SPECIAL_SWICH = 1
#--------------------------------------------------------------------------
# ● 获取开关
# switch_id : 开关 ID
#--------------------------------------------------------------------------
def [](switch_id)
if switch_id == SPECIAL_SWICH and FileTest.exist?("SS_Save.rxdata")
file = File.open("SS_Save.rxdata", "rb")
@data[switch_id] = Marshal.load(file)
file.close
return @data[switch_id]
end
if switch_id <= 5000 and @data[switch_id] != nil
return @data[switch_id]
else
return false
end
end
#--------------------------------------------------------------------------
# ● 设置开关
# switch_id : 开关 ID
# value : ON (true) / OFF (false)
#--------------------------------------------------------------------------
def []=(switch_id, value)
if switch_id <= 5000
@data[switch_id] = value
if switch_id == SPECIAL_SWICH
file = File.open("SS_Save.rxdata", "wb")
Marshal.dump(@data[switch_id], file)
file.close
end
end
end
end
#===============================================================================