Demon
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 > Special Interest > Doom Builder > "Else" in scripts doesn't work
 
Author
All times are GMT. The time now is 01:31. Post New Thread    Post A Reply
blarg
Mini-Member


Posts: 90
Registered: 08-07


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:
code:
#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.

Old Post 04-04-08 00:51 #
blarg is offline Profile || Blog || PM || Search || Add Buddy Report to mod || IP || Edit/Delete || Quote
Steeveeo
Senior Member


Posts: 1011
Registered: 09-06


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.

code:
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

code:
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.

Old Post 04-04-08 03:21 #
Steeveeo is offline Profile || Blog || PM || Search || Add Buddy Report to mod || IP || Edit/Delete || Quote
blarg
Mini-Member


Posts: 90
Registered: 08-07


yeah that worked, thanks.

Old Post 04-04-08 21:01 #
blarg is offline Profile || Blog || PM || Search || Add Buddy Report to mod || IP || Edit/Delete || Quote
Steeveeo
Senior Member


Posts: 1011
Registered: 09-06


Not a problem.

Old Post 04-05-08 01:58 #
Steeveeo is offline Profile || Blog || PM || Search || Add Buddy Report to mod || IP || Edit/Delete || Quote
CodeImp
Moderator


Posts: 1102
Registered: 12-03


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.

__________________
Doom Builder 2 is coming!

Old Post 04-05-08 03:55 #
CodeImp is offline Profile || Blog || PM || Homepage || Search || Add Buddy Report to mod || IP || Edit/Delete || Quote
All times are GMT. The time now is 01:31. Post New Thread    Post A Reply
 
Doomworld Forums : Powered by vBulletin version 2.2.5 Doomworld Forums > Special Interest > Doom Builder > "Else" in scripts doesn't work

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.

Forums Directory