ID:148828
 
mob/verb/timestart()
set hidden = 1
var/hour = text2num(time2text(world.realtime, "hh"))
var/min = time2text(world.realtime, "mm")
var/second = time2text(world.realtime, "ss")
var/ampm = "AM"
time
usr <<"
Time"
if(hour == 0)//12:00AM
if(second == 00)
if (hour > 11)
hour -= 12
ampm = "PM"
if (hour == 0)
hour = 12
world << "The local time is [hour]:[min] [ampm]"
world << "
________"
world << "
It is now midnight and the moon way up in the sky.."
world << "
________"
sleep(10)
goto time
else
sleep(10)
goto time

if(hour == 1)//1:00AM
if(second == 00)
if (hour > 11)
hour -= 12
ampm = "PM"
if (hour == 0)
hour = 12
world << "The local time is [hour]:[min] [ampm]"
sleep(10)
goto time
else
sleep(10)
goto time
You never stated the problem you were having that would really help.
In response to Nadrew
i use been use the verb 1 min before 7:00 and when the time turns 7:00 it wont do any thing.
In response to Nunugi
Everything after "<code>time</code>" shouldn't be indented.
I don't know if it relates to your error, but using goto for this is really a shoddy way to do the loop. Get rid of the time label and do it like this:
while(1)  // you did want this to loop forever, right?
... // do something

And if you want to repeat the loop, use the continue statement instead of "goto time".

Another problem: You're using this same piece of code in every if(). For crying out loud why?
if (hour > 11)
hour -= 12
ampm = "PM"
if (hour == 0)
hour = 12

You should never put something in an if() that's done exactly the same in every block. Put it before your ifs.
var/oldhour=-1
while(1)
var/displayhour=(hour+11)%12+1
var/ampm=(hour<12)?"AM":"PM"
var/hour = text2num(time2text(world.realtime, "hh"))
var/min = time2text(world.realtime, "mm")
var/second = time2text(world.realtime, "ss")
if(hour!=oldhour)
oldhour=hour
world << "The local time is [displayhour]:[min] [ampm]"
// NOW put in your ifs, or better yet a switch
switch(hour)
if(0)
world << "<center><B>It is now midnight, and I can close my HTML tags.</B>"
world << "(Except center, which gives DM fits.)"
world << "I can also use DM tags on the forums."
if(1)
...

And in doing all this I found your problem. From the original code:
if(second == 00)

This was a failure twice over: First, you're comparing text (remember, second would be "00" if it was 0) to a number. Second (pun not intended), you can't be absolutely sure your loop is going to be called on that exact second. This is why in the code above, instead I put in a comparison to oldhour.

Another thing I put in, which you needed, was to not change the hour var for display, but to create a new var for just that purpose. (Or, you can cut out the middleman and put the same formula right in the output line.)
The formula I used might look a little weird, but it's not too bad: Basically, you know you want the displayed hour to be a number from 1 to 12; a modulus of 12 (%12) will give you 0 to 11, so you have to add one. That gives you displayhour=(hour+something)%12+1.

Lummox JR