-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathRS_AutoSave.rb
95 lines (92 loc) · 3.49 KB
/
RS_AutoSave.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#================================================================
# The MIT License
# Copyright (c) 2020 biud436
# ---------------------------------------------------------------
# Free for commercial and non commercial use.
#================================================================
#==============================================================================
# Name : AutoSave
# Author : biud436
# Version : 1.0
#==============================================================================
# ** Terms of Use
#==============================================================================
# Free for commercial and non-commercial use
#==============================================================================
$imported = {} if $imported.nil?
$imported["RS_AutoSave"] = true
#==============================================================================
# module AUTO_SAVE
#==============================================================================
module AUTO_SAVE
TIME = 15;
SLOT = 0;
end
#==============================================================================
# class Game_Map
#==============================================================================
class Game_Map
attr_reader :first_save_time
attr_reader :nnow_save_time
attr_reader :anow_save_time
#==============================================================================
# 클래스 초기화
#==============================================================================
alias ti_initialize initialize
def initialize
ti_initialize
@first_save_time = (Time.now).to_i
@nnow_save_time = (Time.now).to_i
@anow_save_time = 1+(Time.now).to_i
end
#==============================================================================
# 초시계 실시간 계산
#==============================================================================
def up_counter
@nnow_save_time = (Time.now).to_i
end
#==============================================================================
# 초시계 리셋하기
#==============================================================================
def set_counter
@nnow_save_time = (Time.now).to_i
@anow_save_time = AUTO_SAVE::TIME + (Time.now).to_i
end
end
#==============================================================================
# class Game_Player
#==============================================================================
class Game_Player
alias ti_update update
#==============================================================================
# 실시간으로 계산하기
#==============================================================================
def update
ti_update
get_time
end
#==============================================================================
# 초시계 동작
#==============================================================================
def get_time
if $game_map.nnow_save_time >= $game_map.anow_save_time + 1
default_time
$game_map.set_counter;
else
$game_map.up_counter;
end
end
#==============================================================================
# 저장하기
#==============================================================================
def default_time
DataManager.save_game(AUTO_SAVE::SLOT)
$game_map.set_counter
end
#==============================================================================
# 초시계 가져오기
#==============================================================================
def time_now
$game_map.nnow_save_time - $game_map.first_save_time
end
end