getCompleteTime & Me command limited to specific distance.

Started by DizzasTeR, Sep 03, 2015, 09:49 AM

Previous topic - Next topic

Debian

Quote from: Thijn on Sep 03, 2015, 04:38 PMThat time format code could've been a lot shorter,

OnScriptLoad :  seconds <- 0;
 
function onTimeChange(oldHour, oldMin, newHour, newMin)   seconds++;


day <- { d1 = "Monday" d2 = "Tuesday" d3= "Wednesday" d4=  "Thursday" d5= "Friday" d6= "Saturday" d0= "Sunday"}

Print(  "ServerUptime :"+ +day.rawget("d"+(seconds / 86400)% 6) "+ ( seconds / 86400) +"days "+ ( seconds % 86400 / 3600) +"hours "+ ( seconds % 3600 / 60 ) +"minutes " + ( seconds % 60) +"seconds" );
   }

Thijn


Debian

Sorry not used code highlighter
function onScriptLoad(){
  seconds <- 0;
print(  "ServerUptime :"+ +day.rawget("d"+(seconds / 86400)% 6) "+ ( seconds / 86400) +"days "+ ( seconds % 86400 / 3600) +"hours "+ ( seconds % 3600 / 60 ) +"minutes " + ( seconds % 60) +"seconds" );
}
 
function onTimeChange(oldHour, oldMin, newHour, newMin)   seconds++;


day <- { d1 = "Monday" d2 = "Tuesday" d3= "Wednesday" d4=  "Thursday" d5= "Friday" d6= "Saturday" d0= "Sunday"}

DizzasTeR

He didn't mean the code highlighter, he means your code is horrible.

Debian

Yes ,it was not good coding . i made it better now.


local c = clock().tointeger();
day <- { d1 = "Monday" d2 = "Tuesday" d3= "Wednesday" d4=  "Thursday" d5= "Friday" d6= "Saturday" d0= "Sunday"}
        print( "Today"+ day.rawget("d"+(c / 86400)% 6) +"ServerUptime"+ ( c / 86400) +"days "+ ( c % 86400 / 3600) +"hours "+ ( c % 3600 / 60 ) +"minutes " + ( c % 60) +"seconds" );

Thijn

Just stop trying. That code is horrible and there's not much other then completely changing the code to make it even a little bit better.

Locked. This was a snippet release topic, not a "look I post a better piece of code that's actually even worse" topic.