ID:142789
 
Code:
var
minute=1
hour=12
day="Sunday"
date=1
month="Janurary"
ampm="AM"
year=0
proc
TickerLoop()
minute++
if(hour == 12)
if(ampm == "AM")
if(minute >= 1 && minute <= 10)
for(var/mob/M in world)
if(M.client)
if(M.FatigueGain)
var/gain = M.FatigueGain
if(gain <= 0)
gain = 0
M.Fatigue += gain
M.FatigueGain = 0
if(minute==60)
minute=0
hour++
if(hour==12)
if(ampm=="AM")
ampm="PM"
else
ampm="AM"
if(day=="Sunday")
day="Monday"
else if(day=="Monday")
day="Tuesday"
else if(day=="Tuesday")
day="Wednesday"
else if(day=="Wednesday")
day="Thursday"
else if(day=="Thursday")
day="Friday"
else if(day=="Friday")
day="Saturday"
else if(day=="Saturday")
day="Sunday"
date++
if(month=="January"&&date==32)
date=1
month="February"
else if(month=="February")
if(round(year,4)==3000)
if(date==30)
date=1
month="March"
else if(date==29)
date=1
month="March"
else if(month=="March"&&date==32)
date=1
month="April"
else if(month=="April"&&date==31)
date=1
month="May"
else if(month=="May"&&date==32)
date=1
month="June"
else if(month=="June"&&date==31)
date=1
month="July"
else if(month=="July"&&date==32)
date=1
month="August"
else if(month=="August"&&date==32)
date=1
month="September"
else if(month=="September"&&date==31)
date=1
month="October"
else if(month=="October"&&date==32)
date=1
month="November"
else if(month=="November"&&date==31)
date=1
month="December"
else if(month=="December"&&date==32)
date=1
month="Janurary"
year++
else if(hour==13)
hour=1
spawn(20)
TickerLoop()
proc
cardinal(n as num)
switch(n)
if(1||21||31)
return "[n]st"
else if(2||22)
return "[n]nd"
else if(3||23)
return "[n]rd"
else
return "[n]th"


Problem description: Alright the problem is, every second time this proc runs, the minute var goes up by one maybe 1/3 longer than it should. So.. *proc runs* spawn(20) minute++ *loop* spawn(20.5) minute++ *loop* spawn(20) minute ++, etc. Not sure what is causing it. I have other background procs running at the same time, but their mob procs. Thanks.

One important thing to understand is that spawn() and sleep() don't operate on time intervals; the values you pass are in ticks which are approximately 1/10 of a second (but may be longer, depending on what needs processed each tick).

You may also want to look up actual looping structures, rather than spawning off a new proc call every 20 ticks.

Hiead