Current Time BGE

  • September 02, 2015
  • 382 Downloads
  • 4 Likes
  • Blender 2.7x
  • Render: Blender Internal
  • Creator: RedFrost
  • License: CC-0
You must be logged in to download.

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:

  • JDHaller profile picture
    JDHaller

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

    Edited September 02, 2015
  • RedFrost profile picture
    RedFrost

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

    Written September 03, 2015
  • pspmugen profile picture
    pspmugen

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

    Written September 28, 2015
  • RedFrost profile picture
    RedFrost

    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.

    Written September 29, 2015
  • pspmugen profile picture
    pspmugen

    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"])

    Written October 09, 2015
  • RedFrost profile picture
    RedFrost

    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"])

    Written October 09, 2015
  • pspmugen profile picture
    pspmugen

    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 ?

    Written October 12, 2015
  • RedFrost profile picture
    RedFrost
    Written October 12, 2015
  • pspmugen profile picture
    pspmugen

    Thank you, it works.

    Written October 17, 2015
  • puber002 profile picture
    puber002

    awesome

    Written December 10, 2016
  • MORENAVAJ profile picture
    MORENAVAJ

    nice! this is pretty good

    Written February 09, 2017