Timer

From ZDoom Wiki
Jump to: navigation, search

int timer (void)

Usage

Returns the number of tics that have passed since a particular epoch. For maps that are not part of a hub, this will be the time since the level was started. For maps that are part of a hub, this will be the time since the user started a new game.

Examples

A full game timer can be added by adding a script like this to every level in a hub:

script 1 ENTER
{
	int t;
	while(TRUE)
	{
		t = Timer() / 35;
		
		HudMessage(d:t/60, s:":", d:(t%60)/10, d:t%10;
			HUDMSG_PLAIN, 1, CR_RED, 0.95, 0.95, 2.0);
		
		Delay(35);
	}
}

This will only work on hubs, which have to be defined using MAPINFO. It will display and keep track of the total time spent playing in the bottom right corner of the screen.