Advertisement
Threxx

Untitled

Sep 9th, 2022
3,197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /// @description game_timer_new()
  2. function game_timer_new() {
  3.     //Local variables for calculating the time
  4.     var hour, minute, second, centisecond;
  5.  
  6.     //Local variables for displaying the time
  7.     var d_hour, d_minute, d_second, d_centisecond;
  8.    
  9.     var local_limit = 604000000000;
  10.     var global_limit = 362440000000;
  11.    
  12.     if (global.currentTime < local_limit)
  13.         global.currentTime += delta_time;
  14.     if (global.globalTime < global_limit)
  15.         global.globalTime += delta_time;
  16.        
  17.     //Calculate each section of the timer
  18.     var time_to_calculate = global.gameTimer == 1 ? global.currentTime : global.globalTime;
  19.     centisecond =   floor(time_to_calculate / 10000) % 100;
  20.     second =        floor((time_to_calculate / 10000) / 100) % 60;
  21.     minute =        floor(((time_to_calculate / 10000) / 100) / 60) % 60;
  22.     hour =          floor((((time_to_calculate / 10000) / 100) / 60) / 60) % 60;
  23.    
  24.     //Display correct time
  25.     d_hour = global.gameTimer == 1 ? "" : zfill(hour, 2);
  26.     d_minute = zfill(minute, 2);
  27.     d_second = zfill(second, 2);
  28.     d_centisecond = zfill(centisecond, 2);
  29.    
  30.     //Return values
  31.     return [d_hour, d_minute, d_second, d_centisecond];
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement