Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Sign in to follow this  
Tormentor667

"X" Switches to go

Recommended Posts

Hello again, I have a new script request for my ZDoom map. This time I'm looking for a script with which I can do these nice //"x" more to go// effects. What I mean? You place 3 switches in a map and you have to activate all of them to execute another operation. Each time you push one, a hudmessage appears, telling you how many switches are still left do push :)

I need 3 of them. I hope somebody here will be that kind to tell me how to do this (plz. complete script :D)

Share this post


Link to post

Mind you, I'm not really good, and this is partly guesswork, but I understand the basics enough to to this. (and I'm not sure on setting up some things)

script 0 OPEN
{
int var switch1;
switch=0;
     {
     if switch1=1;
     hudmessage(c:Two more to go;);
          {
          if switch=2;
          hudmessage(c:One more to go;);
               {
               if switch=3;
               hudmessage(c:Sequence complete!;);
               switch 1++               
                    {
                    if switch=4;
                    break;
                         {
                         else;
                         repeat;
                         }
                    }
               }
          }
     }
}

script 1 void
{
switch1 1++
}
Mind you, I haven't had much practice, but you get the idea. (some of the syntax is iffy, like the addition)

Share this post


Link to post

Assign each switch line the special "ACS_Execute" with script 1 as first argument. This will work for 3 switches. If you want more switches, just increase the number in count[2] and add more strings between the { }. I.e. for 4 swtiches you would write str count[3]={"three", "two", "one"};. Oh, and don't forget to also increase the number in if(c == 2) to the number you need.

#include "zcommon.acs"

str count[2]={"two", "one"};
int c;

script 1 (void)
{
	if(c == 2) {
		print(s:"do some fancy stuff here");
	}
	else {
		print(s:count[c], s:" more to go");
		c++;
	}
}

Share this post


Link to post

Use "switch" and "case" statements - easier to read, modify, etc.

//=== start example ==
switch(switch1) // just using the name you used
{

case 1: // doesn't have to start at 1
blahblah // nor in sequence
break; // this exits switch code
case 2: // and goes to "next"
more stuff
break;
case ...:
whatever
break;
}

"next" code

//=== end example

You can also put all the strings in one set (as I did with the clock). use messages[switch1] instead of "stringtext". Again cleaner:)

str messages[12]=
{ "first message",
"second message",
"third message",
and so on till you have 12 or whatever
};

In your original, be sure to use "==" not "=" if you want to compare.

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
Sign in to follow this  
×