Page 1 of 1

Display Time and Date?

PostPosted: Wed Dec 02, 2009 9:47 pm
by CrimsonTheDarkBat
Hi, is there a way to display the time and date on an actor? And if possible, can you do so with a selected font and size?

Re: Display Time and Date?

PostPosted: Thu Dec 03, 2009 12:09 pm
by GeoGia
Hi Crimson :)

I don't know what your skill level is. This isn't the simplest thing in the world to do, but it's not too bad

The first thing you wanna do is go to global code and create a variable to hold info about the time:

stTime Clock;

stTime is just like int or char, except it makes a very specialized variable that's tailored to hold time and date info. Clock is just a name you choose. Type something in the box on the bottom and click Add.

Create an actor and click the text button. Type something in so it knows it's a text actor.

Add an event: Draw Actor: Script Editor. The first line you want is this:

Clock = getTime();

This stores all kinds of info about the time and date in Clock. Now for instance, if we wanted the year, we'd type "Clock.year", for hour "Clock.hour". Here's all the possibilities:

Code: Select all
sec: Seconds after minute (0 - 59)
min: Minutes after hour (0 - 59)
hour: Hours since midnight (0 - 23)

mday: Day of month (1 - 31)
mon: Month (1 - 12; January = 1)
year: Year (current year)

wday: Day of week (0 - 6; Sunday = 0)
yday: Day of year (0 - 365)

sec_utc: Number of seconds elapsed since midnight (00:00:00), January 1, 1970 (coordinated universal time)


Now we need to send info to the text of our text actor. If it was just normal text, it would be easy, but since we need numbers, we have to use formatting tricks

sprintf(text,"Time: %i:%i",Clock.hour,Clock,sec);

The first argument, text, just tells it where to put the text, here it just means the text holder of the actor you're in

The %i thingies are special codes that correspond to the arguments after the text in quotes. hour goes into the first %i, sec goes into the second. There are all kinds of codes for different things. %i just accepts an integer

Hope that explains it well enough :) You can change fonts in the text menu, you should see the button there. Good luck!