Advertisement
Dekita

Untitled

Apr 19th, 2014
633
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 18.68 KB | None | 0 0
  1. if true # << Make true to use this script, false to disable.
  2. #===============================================================================
  3. #
  4. # ☆ $D13x - Game Time
  5. # -- Author : Dekita
  6. # -- Version : 1.0
  7. # -- Level : Easy / Normal
  8. # -- Requires : N/A
  9. # -- Engine : RPG Maker VX Ace.
  10. #
  11. #===============================================================================
  12. # ☆ Import
  13. #-------------------------------------------------------------------------------
  14. $D13x={}if$D13x==nil
  15. $D13x[:Game_Time]=true
  16. #===============================================================================
  17. # ☆ Updates
  18. #-------------------------------------------------------------------------------
  19. # D /M /Y
  20. # 2o/o4/2o14 - Finished,
  21. # 11/o4/2o14 - Started
  22. #
  23. #===============================================================================
  24. # ☆ Introduction
  25. #-------------------------------------------------------------------------------
  26. # A simple script to recreate a 'game time' feature. Time will advance during
  27. # your selected scenes. You can then use script calls to check conditions
  28. # for using within your events.
  29. #
  30. # Also creates a simple 'time window' within the menu scene.
  31. #
  32. #===============================================================================
  33. # ★☆★☆★☆★☆★☆★☆★☆★ TERMS AND CONDITIONS: ☆★☆★☆★☆★☆★☆★☆★☆★☆
  34. #===============================================================================
  35. # 1. You MUST give credit to "Dekita" !!
  36. # 2. You are NOT allowed to repost this script.(or modified versions)
  37. # 3. You are NOT allowed to convert this script.
  38. # 4. You are NOT allowed to use this script for Commercial games.
  39. # 5. ENJOY!
  40. #
  41. # "FINE PRINT"
  42. # By using this script you hereby agree to the above terms and conditions,
  43. # if any violation of the above terms occurs "legal action" may be taken.
  44. # Not understanding the above terms and conditions does NOT mean that
  45. # they do not apply to you.
  46. # If you wish to discuss the terms and conditions in further detail you can
  47. # contact me at http://dekitarpg.wordpress.com/
  48. #
  49. #===============================================================================
  50. # ☆ Instructions
  51. #-------------------------------------------------------------------------------
  52. # Place Below " ▼ Materials " and Above " ▼ Main " in your script editor.
  53. #
  54. #===============================================================================
  55. # ☆ Script Calls
  56. #-------------------------------------------------------------------------------
  57. # Game_Time.sec
  58. # Game_Time.min
  59. # Game_Time.hour
  60. # Game_Time.day
  61. # Game_Time.mday
  62. # Game_Time.month
  63. # Game_Time.year
  64. # Game_Time.set_to(sec,min,hour,day,mday,week,month,year)
  65. #
  66. #===============================================================================
  67. # ☆ Notetags ( default )
  68. #-------------------------------------------------------------------------------
  69. # N/A
  70. #
  71. #===============================================================================
  72. # ☆ HELP
  73. #-------------------------------------------------------------------------------
  74. # N/A
  75. #
  76. #===============================================================================
  77. module TIME
  78. #===============================================================================
  79. #-----------------------------------------------------------------------------
  80. # Scenes That Game_Time will update
  81. #-----------------------------------------------------------------------------
  82. UDSC = ['Scene_Map','Scene_Battle']
  83. #-----------------------------------------------------------------------------
  84. # How many frames for 1 second.
  85. #-----------------------------------------------------------------------------
  86. SEC = 2
  87. #-----------------------------------------------------------------------------
  88. # How many secs for 1 minute.
  89. #-----------------------------------------------------------------------------
  90. MIN = 60
  91. #-----------------------------------------------------------------------------
  92. # How many mins for 1 hour.
  93. #-----------------------------------------------------------------------------
  94. HOUR = 60
  95. #-----------------------------------------------------------------------------
  96. # How many hours for 1 day.
  97. #-----------------------------------------------------------------------------
  98. DAY = 24
  99. #-----------------------------------------------------------------------------
  100. # id => ['Day Name', hours in day]
  101. #-----------------------------------------------------------------------------
  102. DAYS = {
  103. 1 => ['Monday' , 24],
  104. 2 => ['Tuesday' , 24],
  105. 3 => ['Wednesday' , 24],
  106. 4 => ['Thursday' , 24],
  107. 5 => ['Friday' , 24],
  108. 6 => ['Saturday' , 24],
  109. 7 => ['Sunday' , 24],
  110. }
  111. #-----------------------------------------------------------------------------
  112. # id => ['Month Name', days in month]
  113. #-----------------------------------------------------------------------------
  114. MONT = {
  115. 1 => ['January' , 31],
  116. 2 => ['Febuary' , 31],
  117. 3 => ['March' , 31],
  118. 4 => ['April' , 31],
  119. 5 => ['May' , 31],
  120. 6 => ['June' , 31],
  121. 7 => ['July' , 31],
  122. 8 => ['August' , 31],
  123. 9 => ['September' , 31],
  124. 10 => ['October' , 31],
  125. 11 => ['November' , 31],
  126. 12 => ['December' , 31],
  127. }
  128. #####################
  129. # CUSTOMISATION END #
  130. end #####################
  131. #☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★#
  132. # #
  133. # http://dekitarpg.wordpress.com/ #
  134. # #
  135. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆#
  136. #===============================================================================#
  137. # ARE YOU MODIFYING BEYOND THIS POINT? \.\. #
  138. # YES?\.\. #
  139. # OMG, REALLY? \| #
  140. # WELL SLAP MY FACE AND CALL ME A DRAGONITE.\..\.. #
  141. # I REALLY DIDN'T THINK YOU HAD IT IN YOU.\..\.. #
  142. #===============================================================================#
  143. class Game_System
  144. #===============================================================================
  145. #-----------------------------------------------------------------------------
  146. #
  147. #-----------------------------------------------------------------------------
  148. attr_accessor :game_time_data
  149. #-----------------------------------------------------------------------------
  150. #
  151. #-----------------------------------------------------------------------------
  152. alias :game_time_data_init :initialize
  153. alias :game_time_on_before_save :on_before_save
  154. alias :game_time_on_after_load :on_after_load
  155. #-----------------------------------------------------------------------------
  156. #
  157. #-----------------------------------------------------------------------------
  158. def initialize
  159. game_time_data_init
  160. Game_Time.setup
  161. end
  162. #-----------------------------------------------------------------------------
  163. #
  164. #-----------------------------------------------------------------------------
  165. def on_before_save
  166. game_time_on_before_save
  167. @game_time_data = Game_Time.data
  168. end
  169. #-----------------------------------------------------------------------------
  170. #
  171. #-----------------------------------------------------------------------------
  172. def on_after_load
  173. game_time_on_after_load
  174. load_game_time
  175. end
  176. #-----------------------------------------------------------------------------
  177. #
  178. #-----------------------------------------------------------------------------
  179. def load_game_time
  180. d = @game_time_data
  181. Game_Time.set_to(d[0],d[1],d[2],d[3],d[4],d[5],d[6],d[7])
  182. end
  183. end
  184. #===============================================================================
  185. module Game_Time
  186. #===============================================================================
  187. #-----------------------------------------------------------------------------
  188. #
  189. #-----------------------------------------------------------------------------
  190. def self.setup
  191. @sec = 0
  192. @min = 0
  193. @hour = 0
  194. @day = 1
  195. @mday = 1
  196. @week = 1
  197. @month = 1
  198. @year = 0
  199. end
  200. #-----------------------------------------------------------------------------
  201. #
  202. #-----------------------------------------------------------------------------
  203. def self.sec ; @sec ; end
  204. def self.sec=(sec) ; @sec = sec ; end
  205. def self.min ; @min ; end
  206. def self.min=(min) ; @min = min ; end
  207. def self.hour ; @hour ; end
  208. def self.hour=(hour) ; @hour = hour ; end
  209. def self.day ; @day ; end
  210. def self.day=(day) ; @day = day ; end
  211. def self.mday ; @mday ; end
  212. def self.mday=(mday) ; @mday = mday ; end
  213. def self.week ; @week ; end
  214. def self.week=(week) ; @week = week ; end
  215. def self.month ; @month ; end
  216. def self.month=(month) ; @month = month ; end
  217. def self.year ; @year ; end
  218. def self.year=(year) ; @year = year ; end
  219. #-----------------------------------------------------------------------------
  220. #
  221. #-----------------------------------------------------------------------------
  222. def self.data
  223. [@sec,@min,@hour,@day,@mday,@week,@month,@year]
  224. end
  225. #-----------------------------------------------------------------------------
  226. #
  227. #-----------------------------------------------------------------------------
  228. def self.set_to(sec,min,hour,day,mday,week,month,year)
  229. @sec = sec
  230. @min = min
  231. @hour = hour
  232. @day = day
  233. @mday = mday
  234. @week = week
  235. @month = month
  236. @year = year
  237. end
  238. #-----------------------------------------------------------------------------
  239. #
  240. #-----------------------------------------------------------------------------
  241. def self.update
  242. update_sec
  243. update_min
  244. update_hour
  245. update_day
  246. # update_mday
  247. update_week
  248. update_month
  249. update_year
  250. end
  251. #-----------------------------------------------------------------------------
  252. #
  253. #-----------------------------------------------------------------------------
  254. def self.update_sec
  255. @sec += 1
  256. end
  257. #-----------------------------------------------------------------------------
  258. #
  259. #-----------------------------------------------------------------------------
  260. def self.update_min
  261. return unless @sec > TIME::MIN
  262. @min += 1
  263. @sec = 0
  264. end
  265. #-----------------------------------------------------------------------------
  266. #
  267. #-----------------------------------------------------------------------------
  268. def self.update_hour
  269. return unless @min > TIME::HOUR
  270. @hour += 1
  271. @min = 0
  272. end
  273. #-----------------------------------------------------------------------------
  274. #
  275. #-----------------------------------------------------------------------------
  276. def self.update_day
  277. return unless @hour > TIME::DAYS[@day][1]
  278. @day += 1
  279. @mday += 1
  280. @hour = 0
  281. end
  282. #-----------------------------------------------------------------------------
  283. #
  284. #-----------------------------------------------------------------------------
  285. def self.update_week
  286. return unless @day > TIME::DAYS.keys.max
  287. @week += 1
  288. @day = 1
  289. end
  290. #-----------------------------------------------------------------------------
  291. #
  292. #-----------------------------------------------------------------------------
  293. def self.update_month
  294. return unless @mday > TIME::MONT[@month][1]
  295. @month += 1
  296. @mday = 0
  297. end
  298. #-----------------------------------------------------------------------------
  299. #
  300. #-----------------------------------------------------------------------------
  301. def self.update_year
  302. return unless @month > TIME::MONT.keys.max
  303. @year += 1
  304. @month = 0
  305. @week = 1
  306. end
  307. end
  308. #===============================================================================
  309. module Game_Time_Updater
  310. #===============================================================================
  311. #-----------------------------------------------------------------------------
  312. #
  313. #-----------------------------------------------------------------------------
  314. @update_timer = 0
  315. #-----------------------------------------------------------------------------
  316. #
  317. #-----------------------------------------------------------------------------
  318. def self.update
  319. @update_timer += 1
  320. complete_update
  321. end
  322. #-----------------------------------------------------------------------------
  323. #
  324. #-----------------------------------------------------------------------------
  325. def self.complete_update
  326. return unless @update_timer >= TIME::SEC
  327. @update_timer = 0
  328. Game_Time.update
  329. end
  330. end
  331. #===============================================================================
  332. class Scene_Base
  333. #===============================================================================
  334. #-----------------------------------------------------------------------------
  335. #
  336. #-----------------------------------------------------------------------------
  337. alias :start_game_time :start
  338. alias :update_game_time :update
  339. #--------------------------------------------------------------------------
  340. # * Start Processing
  341. #--------------------------------------------------------------------------
  342. def start
  343. start_game_time
  344. start_game_tmod
  345. end
  346. #-----------------------------------------------------------------------------
  347. #
  348. #-----------------------------------------------------------------------------
  349. def update
  350. update_game_time
  351. update_game_tmod
  352. end
  353. #-----------------------------------------------------------------------------
  354. #
  355. #-----------------------------------------------------------------------------
  356. def start_game_tmod
  357. @can_update_time_mod = TIME::UDSC.include?(self.class.name.to_s)
  358. @can_update_time_mod = true if TIME::UDSC.empty?
  359. end
  360. #-----------------------------------------------------------------------------
  361. #
  362. #-----------------------------------------------------------------------------
  363. def update_game_tmod
  364. return unless @can_update_time_mod
  365. Game_Time_Updater.update
  366. end
  367. end
  368. #===============================================================================
  369. class Window_Time < Window_Base
  370. #===============================================================================
  371. #-----------------------------------------------------------------------------
  372. #
  373. #-----------------------------------------------------------------------------
  374. def initialize(x,y,w,h)
  375. super(x,y,w,h)
  376. refresh
  377. end
  378. #-----------------------------------------------------------------------------
  379. #
  380. #-----------------------------------------------------------------------------
  381. def widt
  382. self.width-24
  383. end
  384. #-----------------------------------------------------------------------------
  385. #
  386. #-----------------------------------------------------------------------------
  387. def modu
  388. Game_Time
  389. end
  390. #-----------------------------------------------------------------------------
  391. #
  392. #-----------------------------------------------------------------------------
  393. def refresh
  394. contents.clear
  395. draw_game_time
  396. end
  397. #-----------------------------------------------------------------------------
  398. #
  399. #-----------------------------------------------------------------------------
  400. def draw_game_time
  401. draw_time
  402. draw_day
  403. draw_date
  404. end
  405. #-----------------------------------------------------------------------------
  406. #
  407. #-----------------------------------------------------------------------------
  408. def draw_time
  409. text = sprintf("%02d:%02d:%02d",modu.hour,modu.min,modu.sec)
  410. draw_text(0,0,widt,line_height,text,1)
  411. end
  412. #-----------------------------------------------------------------------------
  413. #
  414. #-----------------------------------------------------------------------------
  415. def draw_day
  416. text = "#{TIME::DAYS[modu.day][0]}"
  417. draw_text(0,24,widt,line_height,text,1)
  418. end
  419. #-----------------------------------------------------------------------------
  420. #
  421. #-----------------------------------------------------------------------------
  422. def draw_date
  423. text = "#{TIME::MONT[modu.month][0]}"
  424. draw_text(0,48,widt,line_height,text,0)
  425. draw_text(0,48,widt-4,line_height,modu.mday,2)
  426. end
  427. #-----------------------------------------------------------------------------
  428. #
  429. #-----------------------------------------------------------------------------
  430. def update
  431. super
  432. # refresh
  433. end
  434. end
  435. #===============================================================================
  436. class Scene_Menu < Scene_MenuBase
  437. #===============================================================================
  438. #-----------------------------------------------------------------------------
  439. #
  440. #-----------------------------------------------------------------------------
  441. alias :start_time_window :start
  442. #-----------------------------------------------------------------------------
  443. #
  444. #-----------------------------------------------------------------------------
  445. def start
  446. start_time_window
  447. create_time_window
  448. end
  449. #-----------------------------------------------------------------------------
  450. #
  451. #-----------------------------------------------------------------------------
  452. def create_time_window
  453. x = @gold_window.x
  454. y = @command_window.height
  455. w = @command_window.width
  456. h = Graphics.height-(@command_window.height+@gold_window.height)
  457. @time_window = Window_Time.new(x,y,w,h)
  458. end
  459. end
  460. #==============================================================================#
  461. # http://dekitarpg.wordpress.com/ #
  462. #==============================================================================#
  463. end # if true # << Make true to use this script, false to disable.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement