Advertisement
Madi_Perth

Untitled

Jun 2nd, 2025
572
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. integer time;
  2.  
  3.  /*
  4.   *  Submitted Opensource under GPL 3.0
  5.   *  2010 Fire Centaur
  6.   *  Description:
  7.   *  
  8.   *  Input number of seconds, function will return a string with Days, Hours, Minutes, Seconds
  9.   *  Corrections by Traven Sachs to Display Correct Output allowing for 0 seconds or more than 1 day
  10.   *     and improve readability with whitespace 19-Feb-2011
  11.   */
  12.  
  13. string getTime(integer secs)
  14. {
  15.     string timeStr;
  16.     integer days;
  17.     integer hours;
  18.     integer minutes;
  19.  
  20.     if (secs>=86400)
  21.     {
  22.         days=llFloor(secs/86400);
  23.         secs=secs%86400;
  24.         timeStr+=(string)days+" day";
  25.         if (days>1)
  26.         {
  27.             timeStr+="s";
  28.         }
  29.         if(secs>0)
  30.         {
  31.             timeStr+="\n";
  32.         }
  33.     }
  34.     if(secs>=3600)
  35.     {
  36.         hours=llFloor(secs/3600);
  37.         secs=secs%3600;
  38.         timeStr+=(string)hours+" hour";
  39.         if(hours!=1)
  40.         {
  41.             timeStr+="s";
  42.         }
  43.         if(secs>0)
  44.         {
  45.             timeStr+="\n";
  46.         }
  47.     }
  48.     if(secs>=60)
  49.     {
  50.         minutes=llFloor(secs/60);
  51.         secs=secs%60;
  52.         timeStr+=(string)minutes+" minute";
  53.         if(minutes!=1)
  54.         {
  55.             timeStr+="s";
  56.         }
  57.         if(secs>0)
  58.         {
  59.             timeStr+="\n";
  60.         }
  61.     }
  62.     if (secs>0)
  63.     {
  64.         timeStr+=(string)secs+" second";
  65.         if(secs!=1)
  66.         {
  67.             timeStr+="s";
  68.         }
  69.     }
  70.     return timeStr;
  71. }
  72.  
  73. string loop;
  74. integer total_time;
  75.  
  76. default
  77. {
  78.     state_entry()
  79.     {
  80.         llListen(888, "", "", "START");
  81.     }
  82.     touch_end(integer total_number)
  83.     {
  84.         state start;
  85.     }
  86.    
  87.     listen( integer channel, string name, key id, string message )
  88.     {
  89.         if(message == "START")
  90.             state start;
  91.     }
  92.    
  93. }
  94.  
  95. state start
  96. {
  97.     state_entry()
  98.     {
  99.         time = 0;
  100.         llListen(888, "", "", "");
  101.         llSetTimerEvent(1);
  102.         // loop = "";
  103.         total_time = 0;
  104.     }
  105.     touch_end(integer num)
  106.     {
  107.         state default;
  108.     }
  109.    
  110.     state_exit()
  111.     {
  112.         llSetText(getTime(time),    <0.180, 0.800, 0.251>, 1.0);
  113.         llSetTimerEvent(0);
  114.     }
  115.    
  116.     listen( integer channel, string name, key id, string message )
  117.     {
  118.         //llSay(0, message);
  119.         if(message == "STOP")
  120.         {
  121.             llSetTimerEvent(0);
  122.             llSetText(getTime(time),    <0.180, 0.800, 0.251>, 1.0);
  123.             state default;
  124.         }
  125.         // if(message == "RESET")
  126.         // {
  127.         //     time = 0;
  128.         //     loop += ".";
  129.         // }
  130.     }
  131.    
  132.     timer()
  133.     {
  134.         llSetText(getTime(total_time++),     <1.000, 0.255, 0.212>, 1.0);
  135.     }
  136.    
  137.    
  138.    
  139. }
  140.  
  141.  
  142.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement