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

"Else" in scripts doesn't work

Recommended Posts

I'm relatively new to scripting with Zdoom, and while I've gotten the hang of simply making the script do things, I'm trying to learn how to use the "if" and "else" commands.

When I try to compile a script with "else" in it, DB gives me the message "Invalid command" or something of the sort with invalid in it. I can't figure out what I'm doing wrong, I copied and pasted this from the Zdoom wiki, just edited it so it doesn't just say "command;" beneath the else and if:

#include "zcommon.acs"
script 1 OPEN
{
int fatmama=1;

      if(fatmama==1);
      {
            printbold(s:"Yo mama is fat.");
      }
      else
      {
            printbold(s:"Yo mama is not fat.");
      }
}
I would change the value of "fatmama" to see if the "if" was working, but I never get that far. Once the compiler gets to the line with "else," it gives me the error message. I'm probably just creating the script wrong, but no matter what I try, "else" simply won't work. "If" however, appears to have no problems.

Share this post


Link to post

hmm, I'd say try removing the semicolon after the if statement.

This one works fine until I add a semicolon after my if statement.

int blastshielddown = 0;

script 3 (void) //Big door
{


if(blastshielddown == 0)
	{
		acs_execute(4,0,0,0,0);
	}
else
	{
		acs_execute(5,0,0,0,0);
	}
	delay(175);
}
Compiles fine
int blastshielddown = 0;

script 3 (void) //Big door
{


if(blastshielddown == 0);
	{
		acs_execute(4,0,0,0,0);
	}
else
	{
		acs_execute(5,0,0,0,0);
	}
	delay(175);
}
Does not, and returns an invalid statement error.

Share this post


Link to post

For clarification: if/else is a flow control structure, not a statement. It is because of that that it doesn't have a ; at the end, only statements have that.

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  
×