Doom Marine
Register | User Profile | Member List | F.A.Q | Privacy Policy | New Blog | Search Forums | Forums Home
Doomworld Forums : Powered by vBulletin version 2.2.5 Doomworld Forums > Classic Doom > Doom Editing > Countdown Script?
 
Author
All times are GMT. The time now is 07:44. Post New Thread    Post A Reply
Tormentor667
Senior Member


Posts: 1986
Registered: 10-00


Hi, another Question from me :)

I want to create a Countdown Script, that counts to zero (00:00) from 5 Minutes (05:00). For this I would like to use the following countdown HUDMSG command:

script 111 (void)
{
hudmessage (s:"Timer:\n, s:"05:00"; HUDMSG_PLAIN, 2, CR_WHITE, 1.0, 0.0, 1.0);
delay (35);
hudmessage (s:"Timer:\n, s:"04:59"; HUDMSG_PLAIN, 2, CR_WHITE, 1.0, 0.0, 1.0);
delay (35);
[...]
}

This Scipt would show a countdown number in the top-left screencorner and every second, it would refresh! The problem about it: I don't want to finish this script by writing down about 300 "hudmessages" with the 0x:xx changed every step. Is there a better way to realise this?! (plz gimme the complete script then!)

Old Post 12-06-02 11:21 #
Tormentor667 is offline Profile || Blog || PM || Homepage || Search || Add Buddy IP || Edit || Quote
Anders
No one knows I'm schepe


Posts: 428
Registered: 03-02


try something like this.

code:
script 111 (int counttime) { int i; int mins, secs; str minfill, secfill; for (i = counttime; i >= 0; i--) { mins = i / 60; secs = i % 60; if (mins >= 10) minfill = ""; else minfill = "0"; if (secs >= 10) secfill = ""; else secfill = "0"; hudmessage(s:"Timer:\n", s:minfill, d:mins, s:":", s:secfill, d:secs; HUDMSG_PLAIN, 2, CR_WHITE, 1.0, 0.0, 1.0); delay(35); } }


just give it the number of seconds to countdown (in your case it would be 300) as its argument and it should work. i haven't tested it btw.

__________________
++++++++++[>++++++++++>++++++++++++>+++++++++++>++
+>+<<<<<-]>.>-.>>++.<<<++.>>+.+++.<--.>-----.+++++
+.>.<<<-----.>>-.<<++++.>>>.<<<++.------.>++++.>>>.

Last edited by Anders on 12-06-02 at 14:30

Old Post 12-06-02 12:50 #
Anders is offline Profile || Blog || PM || Homepage || Search || Add Buddy IP || Edit || Quote
The Ultimate DooMer
(former) /newstuff Chronicler


Posts: 4701
Registered: 03-02


AFAIK, there's no built in timer function. What I do is print a message every 10 seconds which shows the time:


printbold(s:"2:00");
delay(350);
printbold(s:"1:50");
delay(350);


and so on until 10 seconds, then I count down every second. (replace printbold with hudmessage in your case)

My timed sections are usually around 2 minutes or less, but I definitely recommend using this method for a 5 minute timer. (saves a lot of script space)

Old Post 12-06-02 12:50 #
The Ultimate DooMer is offline Profile || Blog || PM || Email || Homepage || Search || Add Buddy IP || Edit || Quote
boris
meow


Posts: 3631
Registered: 05-00


There actually is an built in timer functions, it's simply called timer() and returns the level time in tics (i.e. you have to divide by 35 to get the seconds). I don't think it's really useful in this case, since schepe's script will do the job very well.

__________________
this sig is in my pants | WIP - WADs In Progress: post your WADs!

Old Post 12-06-02 15:03 #
boris is offline Profile || Blog || PM || Search || Add Buddy IP || Edit || Quote
Tormentor667
Senior Member


Posts: 1986
Registered: 10-00


Thx for the help and now I have an additional question about this script. How can I add some commands, that will be executed, if the counters minute+second indicator is for example 02:33 or else?! Because I want the timerscipt to teleport enemies in my arena every few seconds :)

Old Post 12-15-02 13:58 #
Tormentor667 is offline Profile || Blog || PM || Homepage || Search || Add Buddy IP || Edit || Quote
boris
meow


Posts: 3631
Registered: 05-00


Just make the mins and secs vars map global and have a self-restarting script that looks for those vars. Something like

code:
script 123 (void) { if (mins == 2 && secs == 33) { // does ACS actually allow &&? I can't remember, heh // do some shit here } delay(1); restart; }

__________________
this sig is in my pants | WIP - WADs In Progress: post your WADs!

Old Post 12-15-02 16:32 #
boris is offline Profile || Blog || PM || Search || Add Buddy IP || Edit || Quote
Tormentor667
Senior Member


Posts: 1986
Registered: 10-00


How can I make the variables global!?!? :(

Old Post 12-20-02 11:50 #
Tormentor667 is offline Profile || Blog || PM || Homepage || Search || Add Buddy IP || Edit || Quote
Ichor
The Mysterious Red Square


Posts: 6940
Registered: 07-02


Let's see if this works:

At the very top of the script, add this to each map:

code:
world int 1: Minutes; // Can be any name world int 2: Seconds; // Same here


Now add this:

code:
script 1 open // Add this script to the first map only { Minutes = 4; Seconds = 60; // 5 minutes total } script 2 (void) // Add this to all maps { Seconds -= 1; if(Seconds < 10) { printbold(d:Minutes,s:":0",d:Seconds,s:" remaining"); } else { printbold(d:Minutes,s:":",d:Seconds,s:" remaining"); } if(Seconds == 0) { Minutes -= 1; Seconds = 60; } if((Minutes == 0) && (Seconds == 0)) { ACS_Execute(10, 2, 0, 0, 0); // Script 10 on map 2. If you're on another map, then the script will run when you get to map 2. } delay(35); // equal to 1 second restart; }

__________________
0.666 - The number of the Millibeast

Last edited by Ichor on 12-20-02 at 14:32

Old Post 12-20-02 12:25 #
Ichor is offline Profile || Blog || PM || Email || Search || Add Buddy IP || Edit || Quote
Tormentor667
Senior Member


Posts: 1986
Registered: 10-00


Thx for the script Ichor but ACS tells me, that there is a missing semicolon after "world" :(

Do I need a new version of acs? And where can i get it?

Old Post 12-20-02 12:41 #
Tormentor667 is offline Profile || Blog || PM || Homepage || Search || Add Buddy IP || Edit || Quote
Ichor
The Mysterious Red Square


Posts: 6940
Registered: 07-02


I think I've worked out all the bugs in it. Try it now.

__________________
0.666 - The number of the Millibeast

Old Post 12-20-02 12:45 #
Ichor is offline Profile || Blog || PM || Email || Search || Add Buddy IP || Edit || Quote
Tormentor667
Senior Member


Posts: 1986
Registered: 10-00


Thx, this one seems to work :) Will test it now :)

Old Post 12-20-02 13:40 #
Tormentor667 is offline Profile || Blog || PM || Homepage || Search || Add Buddy IP || Edit || Quote
Tormentor667
Senior Member


Posts: 1986
Registered: 10-00


Only one problem about it:

When the counter starts @ 4 Minutes and 60 Seconds and counts down to 4 Minutes and 10 Seconds, it looks like this:

Timer: 4:059 (4:010)

and if there are only single numbers to count, from 4 Minutes and 9 seconds on, it looks like this:

Timer: 4:9 (4:8, 4:7)

Looks a bit ugly I think! Is there also a possibility to put the text in the lower or upper left corner? Could you also do this?

Old Post 12-20-02 13:45 #
Tormentor667 is offline Profile || Blog || PM || Homepage || Search || Add Buddy IP || Edit || Quote
boris
meow


Posts: 3631
Registered: 05-00



Tormentor667 said:
Only one problem about it:

When the counter starts @ 4 Minutes and 60 Seconds and counts down to 4 Minutes and 10 Seconds, it looks like this:

Timer: 4:059 (4:010)

and if there are only single numbers to count, from 4 Minutes and 9 seconds on, it looks like this:

Timer: 4:9 (4:8, 4:7)

Looks a bit ugly I think! Is there also a possibility to put the text in the lower or upper left corner? Could you also do this?



Simple replace the line

code:
if(Seconds > 10)


with

code:
if(Seconds < 10)


Just a little typo.

__________________
this sig is in my pants | WIP - WADs In Progress: post your WADs!

Old Post 12-20-02 14:12 #
boris is offline Profile || Blog || PM || Search || Add Buddy IP || Edit || Quote
Ichor
The Mysterious Red Square


Posts: 6940
Registered: 07-02


There, it's fixed.

One little mistake can cause a whole lot of chaos, especially if it doesn't look like one, and I've had more than my share of blunders, heheh.

__________________
0.666 - The number of the Millibeast

Old Post 12-20-02 14:36 #
Ichor is offline Profile || Blog || PM || Email || Search || Add Buddy IP || Edit || Quote
Tormentor667
Senior Member


Posts: 1986
Registered: 10-00


Just one little question *g* : Could you replace the printbold command with hudmessage and change everything in a way, that the message is placed in the upper left corner?!

Old Post 12-20-02 15:31 #
Tormentor667 is offline Profile || Blog || PM || Homepage || Search || Add Buddy IP || Edit || Quote
Ichor
The Mysterious Red Square


Posts: 6940
Registered: 07-02


Well, I don't know most ZDoom specific script commands, since I work with Hexen.

Still, you could try replacing the 'printbold' part with just 'print' and see what happens.

__________________
0.666 - The number of the Millibeast

Old Post 12-20-02 15:52 #
Ichor is offline Profile || Blog || PM || Email || Search || Add Buddy IP || Edit || Quote
Tormentor667
Senior Member


Posts: 1986
Registered: 10-00


This is not what I mean, but thanks though especially for the complete script :)

..TAAARIN, could you eventually help?

Old Post 12-20-02 16:04 #
Tormentor667 is offline Profile || Blog || PM || Homepage || Search || Add Buddy IP || Edit || Quote
The Ultimate DooMer
(former) /newstuff Chronicler


Posts: 4701
Registered: 03-02



Tormentor667 said:
Just one little question *g* : Could you replace the printbold command with hudmessage and change everything in a way, that the message is placed in the upper left corner?!


Yes. (but I don't use it, so I don't know what the exact commands are)

Old Post 12-20-02 17:43 #
The Ultimate DooMer is offline Profile || Blog || PM || Email || Homepage || Search || Add Buddy IP || Edit || Quote
deep
as in Deepsea


Posts: 1066
Registered: 09-01


Personally I prefer just seconds as an argument. Here's another way to do the clock that makes it look PRETTY. Originally this routine was passed a time and a script to execute. I took it out earlier, but it's easy to figure out how to do this. Now let's see if the post comes out ok? [Sorry, you can figure out the spacing - mods can fix:)]


#include "zcommon.acs"

#define SECOND1 35 // 1 second

//=======================================+
// script 1 OPEN startup MESSAGES
//========================================

Script 1 OPEN
{

acs_execute(250,100); // start the countdown timer

}

//=======================================
// A timer Clock for up to 59 minutes 59 seconds
//========================================

str numbers[60] =
{"00","01","02","03","04","05","06","07","08","09",
"10","11","12","13","14","15","16","17","18","19",
"20","21","22","23","24","25","26","27","28","29",
"30","31","32","33","34","35","36","37","38","39",
"40","41","42","43","44","45","46","47","48","49",
"50","51","52","53","54","55","56","57","58","59"};

//=======================================
// script for showing the clock
//=======================================

script 250 (int timedelay)
{
int timeleft;
int minutes;
int seconds;

timeleft = timedelay;

while (timeleft)
{
minutes = timeleft/60;
seconds = timeleft%60;

hudmessage (
s:numbers[minutes],s: ":",s:numbers[seconds];

HUDMSG_PLAIN, // message type
0, // message id
CR_BLUE, // message color
0.45, // x-coordinate
0.6, // y-coordinate
1.0); // hold time (in seconds)

delay(SECOND1);

timeleft--;
}
}

/////// end ///////////////////

Oops, posted the more complicated one first

Last edited by deep on 12-20-02 at 18:13

Old Post 12-20-02 18:01 #
deep is offline Profile || Blog || PM || Email || Homepage || Search || Add Buddy IP || Edit || Quote
Fredrik


Posts: 11687
Registered: 05-00


[code][/code] tags, perhaps?

Old Post 12-20-02 18:04 #
Fredrik is offline Profile || Blog || PM || Email || Homepage || Search || Add Buddy IP || Edit || Quote
Tormentor667
Senior Member


Posts: 1986
Registered: 10-00


@Deep - Thx, but the previous one works fine. My only question is how I can change the printbold into hudmessage so I can put the counter somewhere else :(

Old Post 12-20-02 18:35 #
Tormentor667 is offline Profile || Blog || PM || Homepage || Search || Add Buddy IP || Edit || Quote
deep
as in Deepsea


Posts: 1066
Registered: 09-01



Tormentor667 said:
@Deep - Thx, but the previous one works fine. My only question is how I can change the printbold into hudmessage so I can put the counter somewhere else :(
I don't understand. Just change printbold to a hudmessage. String formatting is identical. Just add the coordinate, etc. stuff.

Old Post 12-20-02 19:53 #
deep is offline Profile || Blog || PM || Email || Homepage || Search || Add Buddy IP || Edit || Quote
Tormentor667
Senior Member


Posts: 1986
Registered: 10-00


I don't know how to :( Could you be so kind and do this for me?

Old Post 12-22-02 20:44 #
Tormentor667 is offline Profile || Blog || PM || Homepage || Search || Add Buddy IP || Edit || Quote
All times are GMT. The time now is 07:44. Post New Thread    Post A Reply
 
Doomworld Forums : Powered by vBulletin version 2.2.5 Doomworld Forums > Classic Doom > Doom Editing > Countdown Script?

Show Printable Version | Email this Page | Subscribe to this Thread

 

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are OFF
[IMG] code is ON
 

< Contact Us - Doomworld >

Powered by: vBulletin Version 2.2.5
Copyright ©2000, 2001, Jelsoft Enterprises Limited.