Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Epyo

Zdoom timer lol

Recommended Posts

Ok so normally I'd figure this out myself but all the Zdoom wads with timers have the scripts locked away.

SO, I want to make a script, that keeps time for how long the player has been in the level. So when the end of the level comes, I can make a hudmessage with your time in it.

I was thinking of making some kind of variable? Like, poop? Then a script would add 1 to poop everysecond, and in the hudmessage at the end of the level I'd have poop. But I have no idea how to add to poop, or create poop, or put poop in the hudmessage. Is there anywhere I can learn this? Is this even possible?

Share this post


Link to post

Ugh, I haven't done ACS in like two years, so this is probably all wrong, but it should be as simple as this:

int poop;

script 1 OPEN
{
    poop = 0;
    while(1)
    {
        delay(35);
        poop++;
    }
}
Then just print poop at the exit, I don't know what the parameters for hudmsg are.

Share this post


Link to post

Or you could simply use the "timer()" function, which returns the level time in tics (i.e. to get seconds, divide the return value by 35).

Share this post


Link to post
boris said:

Or you could simply use the "timer()" function, which returns the level time in tics (i.e. to get seconds, divide the return value by 35).

:)

That was guessable.

Share this post


Link to post

So here's what I got:

script 10 OPEN
{
	int poop;
	
	poop = timer();
	
	poop = poop/35;
	
	str poopfill;
	
	int rootbeer;

    	rootbeer = thingcount(250, 0);
    	if(rootbeer == 0)
    	{
		hudmessage (s:"Your time is", s:poopfill, s:"seconds"; HUDMSG_FADEOUT , 0, CR_green, 0.5, 0.5, 16.0);
		hudmessage (s:"Par is 90 seconds"; HUDMSG_FADEOUT , 0, CR_brick, 0.5, 0.6, 16.0);
		delay(595);
		exit_normal(0);
    	}
	delay(1);
	restart;
}
but then it always says at the level's end: "Your time is bullets seconds". What's up?

Share this post


Link to post

Simple!
You want to print poopfill as an integer not a string. It must read:

hudmessage (s:"Your time is", i:poopfill, s:"seconds"; HUDMSG_FADEOUT , 0, CR_green, 0.5, 0.5, 16.0);

Share this post


Link to post

Well, you'd have to give all things' special to ACS_Execute and let it call a script that increments or decrements some value.

Share this post


Link to post

Or what if the special of each item was to spawn a monster in a secret room far from the rest of the map. Each item would have it's own monster tid and spawnpoint tid. A "thingcount(monster, 0)" would count the monsters in the secret room, and the answer to the thingcount would be put into a hudmessage. There's your counter!

Well I guess that's too complicated, boris's idea is probably easier and better. The monsters would start something like

script 666 (void)
{
 counter++;
}
Yep, when you want the counter to go down you'd use something like counter--, wow there's so much to do with this ++ -- /x == *x stuff, this is all new to me!

Share this post


Link to post

c++ is the same as c = c + 1;
c-- is the same as c = c - 1;
c += x; is the same as c = c + x;
c -= x; is the same as c = c - x;
(same works for *= and /=)

so naturally, c += 1; and c++; are the same thing.

then there's also ++c; which incriments c before it's been used (preincriment, c++ is called a postincriment) in a loop (for instance: c = 1; while(++c < 10) {} will start the while loop with c == 2

and then you have stuff like || which means 'or' and && which means 'and' which are very useful for whiles and ifs and stuff

more still, there's == which is equivalent (not to be confused with =, which is assignment) and also != which is 'not equal to', and you can also use ! to negate things so if(!var) would only execute the statements in the if block if var is 0.

got it?! :P

btw: int poop = timer() / 35; is perfectly valid

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×