#==============================================================================
# 「リアル時刻の取得」(ACE) ver1.0
# 製作者:奈々(なな)
# へぷたなすくろーる http://heptanas.mamagoto.com/
#
# ◇使用規約
# 使用される場合はスクリプト作成者として「奈々」を明記して下さい。
# このスクリプトを改変したり、改変したものを配布するなどは自由ですが
# その場合も元のスクリプトの作成者として名前は載せて下さい。
#
#------------------------------------------------------------------------------
#
# 現実の時刻を(PCの時計から)変数に入れることができます。
# 期間限定イベントや、某ど○ぶつの森のようなシステムにどうぞ。
#
# 使い方はイベントコマンドの「スクリプト」で行います。
# nrt_year(n) 変数n番に年が入ります。
# nrt_month(n) 月
# nrt_day(n) 日
# nrt_hour(n) 時
# nrt_min(n) 分
# nrt_sec(n) 秒
# nrt_wday(n) 曜日(0が日曜、1が月曜...)
#
# また、拡張機能が2つあります。(falseをtrueに変えると有効になる)
# 1つはセーブ時とロード時に日数を変数に取得する機能です。
# ロード時の日数からセーブ時の日数を引けば「何日後に再開したか」が分かります。
#
# もう1つは時刻を常に変数に取得し続ける機能です。
#
#==============================================================================
# ◇拡張機能
module Nana
module Real_Time
#セーブ&ロード時に日数取得
#日数は、一ヶ月が30日、一年が360日と換算
SAVE_LOAD_MODE = false
SAVE_DAYS = 1 #セーブ時に受け取る変数ID
LOAD_DAYS = 2 #ロード時に受け取る変数ID
#常に月〜秒までを取得
ALLWAYS_MODE = false
AW_MONTH = 1 #月を受け取る変数ID
AW_DAY = 2 #日を受け取る変数ID
AW_HOUR = 3 #時を受け取る変数ID
AW_MIN = 4 #分を受け取る変数ID
AW_SEC = 5 #秒を受け取る変数ID
end
end
if Nana::Real_Time::SAVE_LOAD_MODE == true
#==============================================================================
# ■ DataManager
#------------------------------------------------------------------------------
# データベースとゲームオブジェクトを管理するモジュールです。ゲームで使用する
# ほぼ全てのグローバル変数はこのモジュールで初期化されます。
#==============================================================================
module DataManager
#--------------------------------------------------------------------------
# ○ セーブの実行
#--------------------------------------------------------------------------
def self.save_game(index)
x = Time.now
$game_variables[Nana::Real_Time::SAVE_DAYS] = x.year * 360 + x.month * 30 + x.day
begin
save_game_without_rescue(index)
rescue
delete_save_file(index)
false
end
end
#--------------------------------------------------------------------------
# ○ ロードの実行
#--------------------------------------------------------------------------
def self.load_game(index)
load_game_without_rescue(index) rescue false
x = Time.now
$game_variables[Nana::Real_Time::LOAD_DAYS] = x.year * 360 + x.month * 30 + x.day
end
end
end
if Nana::Real_Time::ALLWAYS_MODE == true
#==============================================================================
# ■ Scene_Base
#------------------------------------------------------------------------------
# ゲーム中の全てのシーンのスーパークラスです。
#==============================================================================
class Scene_Base
#--------------------------------------------------------------------------
# ◎ フレーム更新
#--------------------------------------------------------------------------
alias nrt_update update
def update
nrt_update
x = Time.now
$game_variables[Nana::Real_Time::AW_MONTH] = x.month
$game_variables[Nana::Real_Time::AW_DAY] = x.day
$game_variables[Nana::Real_Time::AW_HOUR] = x.hour
$game_variables[Nana::Real_Time::AW_MIN] = x.min
$game_variables[Nana::Real_Time::AW_SEC] = x.sec
end
end
end
#==============================================================================
# ■ Game_Interpreter
#------------------------------------------------------------------------------
# イベントコマンドを実行するインタプリタです。このクラスは Game_Map クラス、
# Game_Troop クラス、Game_Event クラスの内部で使用されます。
#==============================================================================
class Game_Interpreter
#--------------------------------------------------------------------------
# ● 年を変数に代入
#--------------------------------------------------------------------------
def nrt_year(id)
x = Time.now
$game_variables[id] = x.year
end
#--------------------------------------------------------------------------
# ● 月を変数に代入
#--------------------------------------------------------------------------
def nrt_month(id)
x = Time.now
$game_variables[id] = x.month
end
#--------------------------------------------------------------------------
# ● 日を変数に代入
#--------------------------------------------------------------------------
def nrt_day(id)
x = Time.now
$game_variables[id] = x.day
end
#--------------------------------------------------------------------------
# ● 時を変数に代入
#--------------------------------------------------------------------------
def nrt_hour(id)
x = Time.now
$game_variables[id] = x.hour
end
#--------------------------------------------------------------------------
# ● 分を変数に代入
#--------------------------------------------------------------------------
def nrt_min(id)
x = Time.now
$game_variables[id] = x.min
end
#--------------------------------------------------------------------------
# ● 秒を変数に代入
#--------------------------------------------------------------------------
def nrt_sec(id)
x = Time.now
$game_variables[id] = x.sec
end
#--------------------------------------------------------------------------
# ● 曜日を変数に代入(0が日曜)
#--------------------------------------------------------------------------
def nrt_wday(id)
x = Time.now
$game_variables[id] = x.wday
end
end