Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- integer time;
- /*
- * Submitted Opensource under GPL 3.0
- * 2010 Fire Centaur
- * Description:
- *
- * Input number of seconds, function will return a string with Days, Hours, Minutes, Seconds
- * Corrections by Traven Sachs to Display Correct Output allowing for 0 seconds or more than 1 day
- * and improve readability with whitespace 19-Feb-2011
- */
- string getTime(integer secs)
- {
- string timeStr;
- integer days;
- integer hours;
- integer minutes;
- if (secs>=86400)
- {
- days=llFloor(secs/86400);
- secs=secs%86400;
- timeStr+=(string)days+" day";
- if (days>1)
- {
- timeStr+="s";
- }
- if(secs>0)
- {
- timeStr+="\n";
- }
- }
- if(secs>=3600)
- {
- hours=llFloor(secs/3600);
- secs=secs%3600;
- timeStr+=(string)hours+" hour";
- if(hours!=1)
- {
- timeStr+="s";
- }
- if(secs>0)
- {
- timeStr+="\n";
- }
- }
- if(secs>=60)
- {
- minutes=llFloor(secs/60);
- secs=secs%60;
- timeStr+=(string)minutes+" minute";
- if(minutes!=1)
- {
- timeStr+="s";
- }
- if(secs>0)
- {
- timeStr+="\n";
- }
- }
- if (secs>0)
- {
- timeStr+=(string)secs+" second";
- if(secs!=1)
- {
- timeStr+="s";
- }
- }
- return timeStr;
- }
- default
- {
- state_entry()
- {
- llListen(888, "", "", "START");
- }
- touch_end(integer total_number)
- {
- state start;
- }
- listen( integer channel, string name, key id, string message )
- {
- if(message == "START")
- state start;
- }
- }
- state start
- {
- state_entry()
- {
- time = 0;
- llListen(888, "", "", "STOP");
- llSetTimerEvent(1);
- }
- touch_end(integer num)
- {
- state default;
- }
- state_exit()
- {
- llSetText(getTime(time), <0.180, 0.800, 0.251>, 1.0);
- }
- listen( integer channel, string name, key id, string message )
- {
- if(message == "STOP")
- state default;
- }
- timer()
- {
- llSetText(getTime(time++), <1.000, 0.255, 0.212>, 1.0);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement