ACS timer?

Archive of the old editing forum
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
Locked
User avatar
Cutmanmike
Posts: 11354
Joined: Mon Oct 06, 2003 3:41 pm
Operating System Version (Optional): Windows 10
Location: United Kingdom
Contact:

ACS timer?

Post by Cutmanmike »

How would I make a timer in ACS? minutes:seconds:milliseconds that counts up? Also need to to display on the top of the HUD.

I want to squeeze a time trial mode into zportal. :)
User avatar
The Unmaker
Posts: 139
Joined: Sun Mar 30, 2008 3:15 am
Location: Pete's World :D

Re: ACS timer?

Post by The Unmaker »

Use Timer() thhis displays the amount of time since the start of the level in tics, or if the level is part of a hub since the start of the game
User avatar
Cutmanmike
Posts: 11354
Joined: Mon Oct 06, 2003 3:41 pm
Operating System Version (Optional): Windows 10
Location: United Kingdom
Contact:

Re: ACS timer?

Post by Cutmanmike »

But I want to start the timer after a 5 second countdown, and I need to know the best way to display this as minutes:seconds:milliseconds.
User avatar
Enjay
 
 
Posts: 27334
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland
Contact:

Re: ACS timer?

Post by Enjay »

http://zdoom.org/wiki/Timer

I've used it to provide the total time a level or hub was played on an ACS intermission screen...

Code: Select all

int gametime; 
int hr;
int min; 
int sec;

...

gametime = Timer() / 35;

...

hr = gametime/3600; 
min = (gametime/60)%60; 
sec = gametime%60;

...

hudmessagebold(d:hr, s:":", d:min/10, d:min%10, s:":", d:sec/10, d:sec%10; 
		HUDMSG_PLAIN, 215, CR_GRAY, 375.2, 270.1, 0);



but you could add a little extra ACS/maths in to note the time your level timer starts then call the timer (repeatedly) minus whatever that start value was to get the time since the time.
User avatar
The Unmaker
Posts: 139
Joined: Sun Mar 30, 2008 3:15 am
Location: Pete's World :D

Re: ACS timer?

Post by The Unmaker »

Enjay wrote:http://zdoom.org/wiki/Timer

I've used it to provide the total time a level or hub was played on an ACS intermission screen...

Code: Select all

int gametime; 
int hr;
int min; 
int sec;

...

gametime = Timer() / 35;

...

hr = gametime/3600; 
min = (gametime/60)%60; 
sec = gametime%60;

...

hudmessagebold(d:hr, s:":", d:min/10, d:min%10, s:":", d:sec/10, d:sec%10; 
		HUDMSG_PLAIN, 215, CR_GRAY, 375.2, 270.1, 0);



but you could add a little extra ACS/maths in to note the time your level timer starts then call the timer (repeatedly) minus whatever that start value was to get the time since the time.
Brilliant enjay! How did i nt think of that?!

EDIT: Changed the wiki to show your method enjay. I used the one already there ages ago and found it was not sutable :(
User avatar
Cutmanmike
Posts: 11354
Joined: Mon Oct 06, 2003 3:41 pm
Operating System Version (Optional): Windows 10
Location: United Kingdom
Contact:

Re: ACS timer?

Post by Cutmanmike »

Yeah I just found that example. I tried it my own way BUT it doesn't reset the seconds value when a minute passes.

Code: Select all

script 11 ENTER
{
if(timetrial>0){
timetrial++;
}
SetFont("BIGFONT");
SetHudSize(320, 240, 1);
HudMessage(d:timetrial/3600, s:":", d:timetrial/60, s:":", d:(timetrial%60)/10, d:timetrial%10;HUDMSG_PLAIN, 2, CR_WHITE, 160.0, 5.0, 2.0);
Delay(1);
Restart;
}
User avatar
The Unmaker
Posts: 139
Joined: Sun Mar 30, 2008 3:15 am
Location: Pete's World :D

Re: ACS timer?

Post by The Unmaker »

What does the percentage sign do?
User avatar
Cutmanmike
Posts: 11354
Joined: Mon Oct 06, 2003 3:41 pm
Operating System Version (Optional): Windows 10
Location: United Kingdom
Contact:

Re: ACS timer?

Post by Cutmanmike »

Aha, I cracked it. I'm not sure what it's supposed to do but this worked:

Code: Select all

script 11 ENTER
{
timetrial = Timer()-6*35-timededuction;
SetFont("BIGFONT");
SetHudSize(320, 240, 1);
HudMessage(d:timetrial/3600, s:":", d:(timetrial/60)%60, s:":", d:(timetrial%60)/10, d:timetrial%10;HUDMSG_PLAIN, 2, CR_WHITE, 160.0, 5.0, 2.0);
Delay(1);
Restart;
}
User avatar
Enjay
 
 
Posts: 27334
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland
Contact:

Re: ACS timer?

Post by Enjay »

The Unmaker wrote:What does the percentage sign do?
http://en.wikipedia.org/wiki/Modulo_ope ... expression
User avatar
KeksDose
 
 
Posts: 596
Joined: Thu Jul 05, 2007 6:13 pm
Location: my laboratory
Contact:

Re: ACS timer?

Post by KeksDose »

The percentage sign is the modulous operator. It takes the remainder of a calculation using the dividing operator.
17 / 3 is 5, the remainder is 2, that's why 17 % 3 = 2.

A few more examples:
22 % 5 = 2, 37 % 9 = 1, 100 % 9 = 1, 55 % 6 = 1, 87 % 12 = 3.

[EDIT] Damn you, Enjay >_>
User avatar
The Unmaker
Posts: 139
Joined: Sun Mar 30, 2008 3:15 am
Location: Pete's World :D

Re: ACS timer?

Post by The Unmaker »

Thanks you two.

Btw can someone look at a thread i made yesterday i have some questions that i NEED answering! Its here http://forum.zdoom.org/viewtopic.php?f=3&t=17342
Locked

Return to “Editing (Archive)”