Current Time BGE

Description

A pretty handy dandy asset you can use for a game if you need something to happen based on a current time or simply need a real time clock.

I have it so that it shows the seconds as well as minutes and hours but you can change it to display any combination of the current __Year__, __Month__, __Day__, __Hour__, __Minute__, and __Second__. Simply change line __17__ of the script to what you need. Even if you don't know python, I'm sure you can do it.

Comments (10)

J
JDHaller over 10 years ago

Great blend @NicholasAnderson Handy setup Thanks for sharing. :)

R
RedFrost over 10 years ago

There was a problem with the analog clock but I just fixed it; so if you want to download the updated version, please do.

P
pspmugen over 10 years ago

Thanks, but how can to do to always have 2 digits on the digital clock ?

R
RedFrost over 10 years ago

Go into the python script for the digital clock and you should see some lines that say something like `own["seconds"] = datetime.seconds` just delete those lines and it should work.

P
pspmugen over 10 years ago

Sorry but I do not understand. The Python script to the digital clock contains the indicated lines. Here is the script: import bge from bge import logic import datetime cont = bge.logic.getCurrentController() own = cont.owner time = datetime.datetime.now() own["Year"] = time.year own["Month"] = time.month own["Day"] = time.day own["Hour"] = time.hour own["Minute"] = time.minute own["Second"] = time.second own["Text"] = (own["Hour"] + ":" + own["Minute"] + ":" + own["Second"])

R
RedFrost over 10 years ago

Ok in the last line take out from `own["Text"] = (own["Hour"] + ":" + own["Minute"] + ":" + own["Second"])` ` + ":" + own["Second"])` so you get `own["Text"] = (own["Hour"] + ":" + own["Minute"])`

P
pspmugen over 10 years ago

Thanks, but I think you have not understood the question ? or I badly worded in early ! So, for now, your code displays time like that "19:5:2" and I would like to see "19:05:02". How to do ?

P
pspmugen over 10 years ago

Thank you, it works.

P
puber002 over 9 years ago

awesome

M
MORENAVAJ about 9 years ago

nice! this is pretty good

Sign in to leave a comment.