Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

System time in hours or militarty time

0 views
Skip to first unread message

Larsman

unread,
Mar 4, 2005, 12:13:47 AM3/4/05
to
Hello. I?m having a hard time figuring out this next task. I am trying to get
my buttons to rotate to a new spot every hour. I have got everything to work
but I can only figure out how to rotate them every minute. Here is my code on
frame 1

Global gtime
on enterframe
gTime = _system.time()
end

on exitframe
if gTime = _system.time() then
go to the frame
else
go to frame 2
end if
end

On enter frame I have it look at the clock and on exit frame if it is
different then it rotates the buttons on the next frame(2). How can I get this
code to ignore the minutes and only look at the hour? So again it will only go
to the next frame when it sees an hour change and not minute change.

Thanks

-Lars


AstrO

unread,
Mar 4, 2005, 12:45:15 AM3/4/05
to
sorry it should look like this:

on getHour()
tOldItem = _player.itemDelimiter
_player.itemDelimiter = ":"
tTime = _system.time()
if tTime.item[2].word[2] = "PM" then
tTime = integer(tTime.item[1]) + 12
else
tTime = integer(tTime.item[1])
end if
_player.itemDelimiter = tOldItem
return tTime
end

AstrO wrote:
> You could use soemthing like this:
>
> on getHour()
> tOldItem = _player.itemDelimiter
> _player.itemDelimiter = ":"
> tTime = _system.time()
> if tTime.item[2].word[2] = "PM" then
> tTime = integer(tTime.item[1]) + 12
> else
> tTime = integer(tTime.item[1])
> end if
> tTime = integer(tTime.item[1]) + tMod
> _player.itemDelimiter = tOldItem
> return tTime
> end
>
> The above will return the hour as an integer.
>
> AstrO

AstrO

unread,
Mar 4, 2005, 12:41:32 AM3/4/05
to
You could use soemthing like this:

on getHour()
tOldItem = _player.itemDelimiter
_player.itemDelimiter = ":"
tTime = _system.time()
if tTime.item[2].word[2] = "PM" then
tTime = integer(tTime.item[1]) + 12
else
tTime = integer(tTime.item[1])
end if
tTime = integer(tTime.item[1]) + tMod
_player.itemDelimiter = tOldItem
return tTime
end

The above will return the hour as an integer.

AstrO

Larsman

unread,
Mar 4, 2005, 2:57:39 AM3/4/05
to
Thanks Astro, that seems alot different then what I was thinking it would be. I
will copy that code but I would like to understand it first so I can make
changes to it if need be. This piece of code confuses me--
_player.itemDelimiter -- I can understand most of it but I have no idea what
that does.

Thanks for the help

-Lars

Andrew Morton

unread,
Mar 4, 2005, 3:43:45 AM3/4/05
to
Assuming you only want the change to occur every sixty minutes rather than
on the hour,

property pTimer, pDelay

on beginSprite
pDelay=60*60*1000 -- 60min*60sec*1000ms
pTimer=the milliseconds
end beginSprite

on exitFrame
if the milliseconds-pTimer>=pDelay then
pTimer=the milliseconds
-- one hour is up
end if
end exitFrame

Andrew


AstrO

unread,
Mar 4, 2005, 5:16:00 AM3/4/05
to
[ From the help file ]
itemDelimiter; Player property; indicates the special character used to
separate items.

You can use the itemDelimiter to parse filenames by setting
itemDelimiter to a backslash (\) in Windows or a colon (:) on the
Macintosh. Restore the itemDelimiter character to a comma (,) for normal
operation.
/end

What the itemDelimiter lets me do is access a section of the
_system.time() string. By default the itemDelimiter is ',' and if I
wanted to get item 2 of this string '1234,32,435,2123,564' it would
return '32'. In out case I've set the itemDelimiter to ':' so that I can
get the hour and min of the time string which looks something like this
'3:24 PM'. When I ask for item 1 it returns this '3' when I ask for item
2 it returns this '24 PM'. Just for note word 2 of the time string
should always be either 'PM' or 'AM' so it's easy to convert 12 hour
time into 24 hour.

I hope this is what you were looking for.

AstrO

Larsman

unread,
Mar 4, 2005, 3:57:12 PM3/4/05
to
Interesting my last reply didn;t work.

So again, thanks for breaking it down for me. I did read the help file but
didn't uderstand it to well, your breakdown helped. I looked at the timer idea
but I already have a timer running. I don't know if you can have 2 timers
running at the same time. At this point I don't need to turn it into military
time since it seems like your code will work.

thanks again, Lars

Sean Wilson

unread,
Mar 7, 2005, 10:38:30 PM3/7/05
to
Andrew's suggestion of using the milliseconds will work, but it seems
wasteful to check every exitFrame for something that needs to happen
once an hour. That looks more like a job for a timeout object.
And one other option:
put (the systemDate).seconds/(60 * 60)
-- 16
0 new messages