Advertisement
Guest User

Seabass Time System

a guest
Nov 8th, 2015
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /==\ CREATE EVENT /==\
  2. /// Game System Initialize
  3.  
  4. game_time_pause = false;
  5. game_time_seconds = 0;
  6. game_time_minutes = 0;
  7. game_time_hours = 14;
  8. game_time_day = 1;
  9. game_time_month = 1;
  10. game_time_year = 1;
  11. game_time_speed = 0;
  12. game_world_date = string(game_time_day)+"/"+string(game_time_month)+" Year "+string(game_time_year);
  13.  
  14. // Write out month and day names
  15. game_day_name = ds_list_create();
  16. ds_list_add(game_day_name,"Monday");
  17. ds_list_add(game_day_name,"Tuesday");
  18. ds_list_add(game_day_name,"Wednesday");
  19. ds_list_add(game_day_name,"Thursday");
  20. ds_list_add(game_day_name,"Friday");
  21. ds_list_add(game_day_name,"Saturday");
  22. ds_list_add(game_day_name,"Sunday");
  23.  
  24. game_month_name = ds_list_create();
  25. ds_list_add(game_month_name,"January");
  26. ds_list_add(game_month_name,"February");
  27. ds_list_add(game_month_name,"March");
  28. ds_list_add(game_month_name,"April");
  29. ds_list_add(game_month_name,"May");
  30. ds_list_add(game_month_name,"June");
  31. ds_list_add(game_month_name,"July");
  32. ds_list_add(game_month_name,"August");
  33. ds_list_add(game_month_name,"September");
  34. ds_list_add(game_month_name,"October");
  35. ds_list_add(game_month_name,"November");
  36. ds_list_add(game_month_name,"December");
  37.  
  38. game_month_day_count = ds_list_create();
  39. ds_list_add(game_month_day_count,31);
  40. ds_list_add(game_month_day_count,28);
  41. ds_list_add(game_month_day_count,31);
  42. ds_list_add(game_month_day_count,30);
  43. ds_list_add(game_month_day_count,31);
  44. ds_list_add(game_month_day_count,30);
  45. ds_list_add(game_month_day_count,31);
  46. ds_list_add(game_month_day_count,31);
  47. ds_list_add(game_month_day_count,30);
  48. ds_list_add(game_month_day_count,31);
  49. ds_list_add(game_month_day_count,30);
  50. ds_list_add(game_month_day_count,31);
  51.  
  52.  
  53.  
  54. /==\ STEP EVENT /==\
  55.  
  56. /// game_time_step()
  57.  
  58. /*
  59.    This script allows the game to step forward in time
  60.    while also accounting for various condition. This script
  61.    should be called in each step that you would like time
  62.    to step forward.
  63.  
  64.    You can increment the seconds by up to 60,
  65.    minutes by up to 60, hours by up to 24,
  66.    days by up to however many days are in that month,
  67.    months by up to 12, and years by as many as you want.
  68. */
  69.  
  70. gml_pragma("forceinline"); // Boosts YYC performance, increases memory usage
  71.  
  72. // game_time_speed is a mode of time progression
  73. switch(game_time_speed)
  74. {
  75. case 0:{game_time_seconds+=2/room_speed;break;} // Normal Speed
  76. case 1:{game_time_seconds+=45/room_speed;break;} // Fast Speed
  77. case 2:{game_time_seconds+=30+5/room_speed;break;} // Sanic Speed
  78. }
  79.  
  80. // Seconds
  81. if ( game_time_seconds > 59 )
  82. {
  83. game_time_minutes++;
  84. game_time_seconds -= 60;
  85. game_time_seconds = clamp(game_time_seconds,0,60);
  86. }
  87.  
  88. // Minutes
  89. if ( game_time_minutes > 59 )
  90. {
  91. game_time_hours++;
  92. game_time_minutes -= 60;
  93. game_time_minutes = clamp(game_time_minutes,0,60);
  94. }
  95.  
  96. // Hours
  97. if ( game_time_hours > 24 )
  98. {
  99. game_time_hours -= 24;
  100. game_time_hours = clamp(game_time_hours,1,25);
  101. game_time_day++;
  102. game_world_date = string(game_time_day)+"/"+string(game_time_month)+" Year "+string(game_time_year);
  103. }
  104.  
  105. // Months
  106. if ( game_time_day > game_month_day_count[|game_time_month] )
  107. {
  108. game_time_day = 1;
  109. game_time_month ++;
  110. game_time_month = clamp(game_time_month,1,13);
  111. game_world_date = string(game_time_day)+"/"+string(game_time_month)+" Year "+string(game_time_year);
  112. }
  113.  
  114. // Years
  115. if ( game_time_month > 12 )
  116. {
  117. game_time_month = 1;
  118. game_time_year++;
  119. game_world_date = string(game_time_day)+"/"+string(game_time_month)+" Year "+string(game_time_year);
  120. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement