ID:1931337
 
(See the best response by Ter13.)
Code:
var
seconds = 0
minutes1 = 0
minutes1_max = 9
minutes2 = 0
hour = 6
ToD = "AM"
time

world
New()
set background = 1
..()
spawn()
while (src)
sleep (3)
if (seconds <= 1)
seconds ++
else
seconds = 0
if (minutes1 <= 8)
minutes1 ++
else
minutes1 = 0
minutes2 ++
if (minutes2 >= 6)
hour ++
Shadow_change()
Save_Time()
minutes2 = 0
if (hour >= 12)
hour = 1
if (hour >= 12)
switch(ToD)
if("AM")
ToD = "PM"
if("PM")
ToD = "AM"
spawn(1)Time()
Save_Time()
get_time()

var
day=0
month=0
year=1500
world
proc
Save_Time()
var/savefile/save
save = new ("Time and Calendar/Current Time.sav")
save[day] << day
save[month] << month
save[year] << year
Load_Time()
var/savefile/load
load = new ("Time and Calendar/Current Time.sav")
load[day] >> day
load[month] >> month
load[year] >> year
Time()
day+=1
if(day==30)
day=1
month+=1
if(month==12)
year+=1
month=1
world<<output("It is now Year [year], Day [day], of Month [month].","chatoutput")



And the obj i want to auto update

obj/Timer
icon='hud_timer.dmi'
icon_state="background"
screen_loc="2,13"
layer=MOB_LAYER+2
New(client/c)
var/icon/min=new('hud_timer.dmi',"[hour]")
var/icon/sec1= minutes1 < 10 ? new('hud_timer.dmi',"0") : new('hud_timer.dmi',"[copytext(num2text(minutes1),1,2)]")
var/icon/sec2= minutes2 < 10 ? new('hud_timer.dmi',"[minutes2]") : new('hud_timer.dmi',"[copytext(num2text(minutes2),2)]")
sec1.Shift(EAST,13)
sec2.Shift(EAST,22)
src.overlays+=min
src.overlays+=sec1
src.overlays+=sec2
c.screen+=src
mob/verb
Show_Clock()
tick_timer()

mob/proc/tick_timer()
for(var/obj/Timer/t in src.client.screen)
var/icon/min=new('hud_timer.dmi',"[hour]")
var/icon/sec1= minutes1 < 10 ? new('hud_timer.dmi',"0") : new('hud_timer.dmi',"[copytext(num2text(minutes1),1,2)]")
var/icon/sec2= minutes2 < 10 ? new('hud_timer.dmi',"[minutes2]") : new('hud_timer.dmi',"[copytext(num2text(minutes2),2)]")
sec1.Shift(EAST,13)
sec2.Shift(EAST,22)
t.overlays=null
t.overlays+=min
t.overlays+=sec1
t.overlays+=sec2


I'm not getting a error but I want it to update on the players screen
It's a in game clock so the work has it's own time.


I don't see where you're creating a new /obj/Timer.
sorry it's in login proc
In response to Kaiochao
So like I said the clock shows up but doesn't change states as the time goes by.
Add the object to a global list on that object's new()

Then have the world loop to tick up the time also loop thru every object in that list calling tick_timer() on the object.

(speaking of that, you should move tick_timer to the object, not the mob, as it should be the object's responsibility to update itself, not the mob's)
Best response
for(var/obj/Timer/t in src.client.screen)


This is a pattern that should never, ever under any circumstance be done.

You should never have to check for a series of objects in the client's screen because if the objects are relevant, they should have a spare reference laying around that you can access them by directly.

As for this timer, you are doing way too much work.

Take a look at this realtime timer for an example of what you can do for your fake timer:

world
New()
. = ..()
keep_time()
var
time_string
proc
keep_time()
set waitfor = 0
var/tstamp
var/hstamp
while(1)
tstamp = world.timeofday
hstamp = "AM"
if(tstamp>=432000) //converts to 12 hour time
tstamp -= 432000
hstamp = "PM"
else if(tstamp<36000) //prevents 12:00 AM from being 00:00 AM
tstamp += 432000
time_string = "[round(tstamp/36000)]:[time2text(tstamp,"mm:ss")] [hstamp]"
sleep(10)

obj
screen_timer
layer = HUD_LAYER
maptext_width = 128
maptext_height = 32
screen_loc = "CENTER:-48,NORTH"
var
active = 0
proc
Update()
set waitfor = 0
if(active)
return
active = 1
while(active)
maptext = "<center>[global.time_string]</center>"
sleep(10)
New()
Update()

client
var
obj/screen_timer
proc
BuildHUD()
screen_timer = new/obj/screen_timer()
screen += screen_timer
New()
. = ..()
if(.)
BuildHUD()
In response to MrStonedOne
Yeah but when I try to get it to update itself the proc becomes undefined it confuses me. I usually do simple coding but I'm trying to get deeper into byond programming system.
In response to Ter13
Wow, I always over complicate things... This works as a formula for me and I converted it to game time and it work
pretty well. Thank you once again Ter