Page 1 of 1

"Bad Syntax"

Posted: April 16th, 2010, 3:58 pm
by BatterY
I had a script compile error, and didn't know what to do, so i read the topic which said that /developer 1 would help.
I did that but now it shows the part of my gsc that i cant find a problem

the thread which CoD complains about:

Code: Select all

door()
{
door1 = getent("door_l","targetname");
door2 = getent("door_r","targetname");
trigger = getent("enter","targetname");
while(1)
{
trigger waittill("trigger");
if level.code == level.answer; // this is the one that it complains
user iprintlnbold("Correct Code ^6:D");
door1 moveX(-8,1,0.5,0.5);
door1 waittill("movedone");
door2 moveX(-8,1,0.5,0.5);
door2 waittill("movedone");
door1 moveY(-24,1,0.5,0.5);
door1 waittill("movedone");
door2 moveY(24,1,0.5,0.5);
door2 waittill("movedone");
wait 2;
door1 moveY(24,1,0.5,0.5);
door1 waittill("movedone");
door2 moveY(-24,1,0.5,0.5);
door2 waittill("movedone");
door1 moveX(8,1,0.5,0.5);
door1 waittill("movedone");
door2 moveX(8,1,0.5,0.5);
door2 waittill("movedone");
wait 5;
else
user iprintlnbold("Wrong Code, Try Again");
level.code = "";
wait 5;
}
}

Re: "Bad Syntax"

Posted: April 16th, 2010, 4:46 pm
by waywaaaard
Basic understanding of scripting is missing I guess. Look at Drofder's Scripting Guide. You need braces for your condition.

http://pastebin.com/XC6e9y7q here version with highlighted bits and syntax highlighting

Code: Select all

door(){
	door1 = getent("door_l","targetname");
	door2 = getent("door_r","targetname");
	trigger = getent("enter","targetname");
	while(1){
		trigger waittill("trigger");
		if(level.code == level.answer){
			user iprintlnbold("Correct Code ^6:D");
			door1 moveX(-8,1,0.5,0.5);
			door1 waittill("movedone");
			door2 moveX(-8,1,0.5,0.5);
			door2 waittill("movedone");
			door1 moveY(-24,1,0.5,0.5);
			door1 waittill("movedone");
			door2 moveY(24,1,0.5,0.5);
			door2 waittill("movedone");
			wait 2;
			door1 moveY(24,1,0.5,0.5);
			door1 waittill("movedone");
			door2 moveY(-24,1,0.5,0.5);
			door2 waittill("movedone");
			door1 moveX(8,1,0.5,0.5);
			door1 waittill("movedone");
			door2 moveX(8,1,0.5,0.5);
			door2 waittill("movedone");
			wait 5;
		}else{
			user iprintlnbold("Wrong Code, Try Again");
			level.code = "";
			wait 5;
		}
}

Re: "Bad Syntax"

Posted: April 16th, 2010, 5:01 pm
by BatterY
thanks, but was it "Learn from your mistakes" ?

EDIT:
haha, you forgot to add one "}" in the end :lol:

Re: "Bad Syntax"

Posted: April 16th, 2010, 5:10 pm
by waywaaaard
Yeah of course but try to read the guide so you get known to the basic constructs of the language.