ID:160957
 
Just wondering if someone can help me find a way to reduce this proc:

Basically I want it to set the _day, _month and _hour vars into numbers(well text, but numbers replacing letters <.<) using realtime.

var/_day=""
var/_hour=""
var/_month=""
var/_year="2008"
world
proc
ServerRealTime()
set background=1
spawn while(1)
var/_time=time2text(realtime)
if(findtext(_time,"Jan",1,0))
_month="01"
else if(findtext(_time,"Feb",1,0))
_month="02"
else if(findtext(_time,"Mar",1,0))
_month="03"
else if(findtext(_time,"Apr",1,0))
_month="04"
else if(findtext(_time,"May",1,0))
_month="05"
else if(findtext(_time,"Jun",1,0))
_month="06"
else if(findtext(_time,"Jul",1,0))
_month="07"
else if(findtext(_time,"Aug",1,0))
_month="08"
else if(findtext(_time,"Sep",1,0))
_month="09"
else if(findtext(_time,"Oct",1,0))
_month="10"
else if(findtext(_time,"Nov",1,0))
_month="11"
else if(findtext(_time,"Dec",1,0))
_month="12"
if(findtext(_time,"01",8,11))
_day="01"
else if(findtext(_time,"02",8,11))
_day="02"
else if(findtext(_time,"03",8,11))
_day="03"
else if(findtext(_time,"04",8,11))
_day="04"
else if(findtext(_time,"05",8,11))
_day="05"
else if(findtext(_time,"06",8,11))
_day="06"
else if(findtext(_time,"07",8,11))
_day="07"
else if(findtext(_time,"08",8,11))
_day="08"
else if(findtext(_time,"09",8,11))
_day="09"
else if(findtext(_time,"10",8,11))
_day="10"
else if(findtext(_time,"11",8,11))
_day="11"
else if(findtext(_time,"12",8,11))
_day="12"
else if(findtext(_time,"13",8,11))
_day="13"
else if(findtext(_time,"14",8,11))
_day="14"
else if(findtext(_time,"15",8,11))
_day="15"
else if(findtext(_time,"16",8,11))
_day="16"
else if(findtext(_time,"17",8,11))
_day="17"
else if(findtext(_time,"18",8,11))
_day="18"
else if(findtext(_time,"19",8,11))
_day="19"
else if(findtext(_time,"20",8,11))
_day="20"
else if(findtext(_time,"21",8,11))
_day="21"
else if(findtext(_time,"22",8,11))
_day="22"
else if(findtext(_time,"23",8,11))
_day="23"
else if(findtext(_time,"24",8,11))
_day="24"
else if(findtext(_time,"25",8,11))
_day="25"
else if(findtext(_time,"26",8,11))
_day="26"
else if(findtext(_time,"27",8,11))
_day="27"
else if(findtext(_time,"28",8,11))
_day="28"
else if(findtext(_time,"29",8,11))
_day="29"
else if(findtext(_time,"30",8,11))
_day="30"
else if(findtext(_time,"31",8,11))
_day="31"
if(findtext(_time,"00",11,14))
_hour="00"
else if(findtext(_time,"01",11,14))
_hour="01"
else if(findtext(_time,"02",11,14))
_hour="02"
else if(findtext(_time,"03",11,14))
_hour="03"
else if(findtext(_time,"04",11,14))
_hour="04"
else if(findtext(_time,"05",11,14))
_hour="05"
else if(findtext(_time,"06",11,14))
_hour="06"
else if(findtext(_time,"07",11,14))
_hour="07"
else if(findtext(_time,"08",11,14))
_hour="08"
else if(findtext(_time,"09",11,14))
_hour="09"
else if(findtext(_time,"10",11,14))
_hour="10"
else if(findtext(_time,"11",11,14))
_hour="11"
else if(findtext(_time,"12",11,14))
_hour="12"
else if(findtext(_time,"13",11,14))
_hour="13"
else if(findtext(_time,"14",11,14))
_hour="14"
else if(findtext(_time,"15",11,14))
_hour="15"
else if(findtext(_time,"16",11,14))
_hour="16"
else if(findtext(_time,"17",11,14))
_hour="17"
else if(findtext(_time,"18",11,14))
_hour="18"
else if(findtext(_time,"19",11,14))
_hour="19"
else if(findtext(_time,"20",11,14))
_hour="20"
else if(findtext(_time,"21",11,14))
_hour="21"
else if(findtext(_time,"22",11,14))
_hour="22"
else if(findtext(_time,"23",11,14))
_hour="23"
else if(findtext(_time,"24",11,14))
_hour="00"
sleep(18000)
world.ServerRealTime()
Did you even looked up time2text()? The second argument is so much easier for you to deal with.

Here's an example:
month = time2text(world.realtime,"MM")
That returns "XX", where XX is the # of the month (ex: "02" for Feb)

If the second argument is MMM, it would have returned (for example) Feb and "Month" would return February.

Other similar formats are listed in the DM reference, look up time2text().
In response to GhostAnime
Totally passed by me.
Thanks Ghost helped a lot.