I want to squeeze a time trial mode into zportal.
ACS timer?
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.
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.
- Cutmanmike
- Posts: 11354
- Joined: Mon Oct 06, 2003 3:41 pm
- Operating System Version (Optional): Windows 10
- Location: United Kingdom
- Contact:
ACS timer?
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.
I want to squeeze a time trial mode into zportal.
- The Unmaker
- Posts: 139
- Joined: Sun Mar 30, 2008 3:15 am
- Location: Pete's World :D
Re: ACS timer?
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
- Cutmanmike
- Posts: 11354
- Joined: Mon Oct 06, 2003 3:41 pm
- Operating System Version (Optional): Windows 10
- Location: United Kingdom
- Contact:
Re: ACS timer?
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.
Re: ACS timer?
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...
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.
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.
- The Unmaker
- Posts: 139
- Joined: Sun Mar 30, 2008 3:15 am
- Location: Pete's World :D
Re: ACS timer?
Brilliant enjay! How did i nt think of that?!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.
EDIT: Changed the wiki to show your method enjay. I used the one already there ages ago and found it was not sutable
- Cutmanmike
- Posts: 11354
- Joined: Mon Oct 06, 2003 3:41 pm
- Operating System Version (Optional): Windows 10
- Location: United Kingdom
- Contact:
Re: ACS timer?
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;
}- The Unmaker
- Posts: 139
- Joined: Sun Mar 30, 2008 3:15 am
- Location: Pete's World :D
Re: ACS timer?
What does the percentage sign do?
- Cutmanmike
- Posts: 11354
- Joined: Mon Oct 06, 2003 3:41 pm
- Operating System Version (Optional): Windows 10
- Location: United Kingdom
- Contact:
Re: ACS timer?
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;
}Re: ACS timer?
http://en.wikipedia.org/wiki/Modulo_ope ... expressionThe Unmaker wrote:What does the percentage sign do?
Re: ACS timer?
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 >_>
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 >_>
- The Unmaker
- Posts: 139
- Joined: Sun Mar 30, 2008 3:15 am
- Location: Pete's World :D
Re: ACS timer?
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
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

