Little Fighter Empire - Forums
Error: expected expression value - Printable Version

+- Little Fighter Empire - Forums (https://lf-empire.de/forum)
+-- Forum: Little Fighter 2 Zone (https://lf-empire.de/forum/forumdisplay.php?fid=7)
+--- Forum: AI Scripting (https://lf-empire.de/forum/forumdisplay.php?fid=56)
+--- Thread: Error: expected expression value (/showthread.php?tid=8110)



Error: expected expression value - A-Man - 07-30-2012

So i decided to rewrite all the old AI chai script to the new angel script AI's.BUT, i keep getting this error: "expected expression value".
Why is that? what did i do wrong??
here is a very simple short code that produces the error:
    C-Code:
int ego(){
 
    A(0,0); //reset keys
    D(0,0);
    J(0,0);
    up(0,0);
    down(0,0);
    left(0,0);
    right(0,0);
 
    for (int i = 0; i < 400; i++){ //target
        if (loadTarget(i) == 0 && target.num != self.num && target.hp > 0 && target.id < 100 && target.team != self.team){
            break;
        }
    }
 
 
    int xdist = target.x-self.x;
    int ydist = target.y-self.y;
    int zdist = target.z-self.z;
    int selfacing;
    int random = rand(4);
 
 
 
if (((self.x-target.x) => 0) && ((self.x-target.x) =< 80)){
  left()
}
return 1;
 
}

This code is small, simple AND useless. But still, i keep getting the same error in the "if (((self.x-target.x) => 0) && ((self.x-target.x) =< 80)){" line.
Any kind of help is appreciated.


RE: Error: expected expression value - Boop - 07-30-2012

>= and <= instead of => and =< (maybe?)

also missing ; after left().

also too many brackets

Code:
if (self.x-target.x >= 0 && self.x-target.x >= 80) { left(); }



RE: Error: expected expression value - A-Man - 07-30-2012

SSSSSSSSSSSSSS!!! It worked!! thanx dude!
@YinYin: Please update your tut. its <= not =<.
Ok. I got another problem and i though it would be stupid if i made another thread for it.
Well, It went fine, then i started getting this error: Expected ';'
I guess i did all the semi colons pretty fine. Here is my code:
    C-Code:
int ego(){
 
 
    int xdist = target.x-self.x;
    int ydist = target.y-self.y;
    int zdist = target.z-self.z;
    int xdista = (target.x-self.x)*(2*self.facing-1);
 
    int random = rand(4);
 
 
 
if (zdist >= 5)
{up();
}elseif (zdist <= -5)
{down();
}elseif (zdist <= 5)
{up(0,0);
}elseif (zdist >= -5)
{down(0,0);
}
 
if (zdist >= 5 && zdist <= -5 && xdista <= 45)
{
DuJ();
} 
 
 
 
return 1;
 
}

Help AGAIN!
Ok, I fixed that error now. It was because i typed "elseif" when the right thing is "else if". But, AGAIN, I got another error i once had in the morning. Error: No conversion from 'bool' to math type available . here is the code:
    C-Code:
int ego(){
 
 
    int xdist = target.x-self.x;
    int ydist = target.y-self.y;
    int zdist = target.z-self.z;
    int xdista = (target.x-self.x)*(2*self.facing-1);
 
    int random = rand(4);
 
 
 
if (zdist >= 5)
{
up();
}else if (zdist <= -5)
{
down();
}else if (zdist <= 5)
{
up(0,0);
}else if (zdist >= -5)
{
down(0,0);
}
 
if (zdist >= 5 && zdist <= -5 && xdista <= 45)
{
DuJ();
} 
return 1;
}




RE: Error: expected expression value - Boop - 07-30-2012

self.facing is a bool rather than an int (blame SomeoneElse he changed it). Also post the line the error happens on so people don't have to look everywhere. You could do:

Code:
int tempFacing; if (self.facing) { tempFacing = 1; } else { tempFacing = 0; } int xdista = (target.x-self.x)*(2*tempFacing-1);

Anyway you god damn read about this(http://lf-empire.de/forum/thread-7927-post-153289.html#pid153289), and even posted about it! http://lf-empire.de/forum/thread-7927-post-153292.html#pid153292

Clearly proof that people don't read things and just post for some strange reason unknown to me.


RE: Error: expected expression value - A-Man - 07-30-2012

Ok man. As that was suppose convert the bool value inside to int. That code it self got errors:
ai/10.as(2, 5): Error: Expected expression value
ai/10.as(9, 1): Error: Expected expression value

Code:
int ego(){ int tempFacing: if (self.facing) { tempFacing = 1; } else { tempFacing = 0; } int xdist = target.x-self.x; int ydist = target.y-self.y; int zdist = target.z-self.z; int xdista = (target.x-self.x)*(2*tempFacing-1); int random = rand(4); if (zdist >= 5) { up(); }else if (zdist <= -5) { down(); }else if (zdist <= 5) { up(0,0); }else if (zdist >= -5) { down(0,0); } if (zdist >= 5 && zdist <= -5 && xdista <= 45) { DuJ(); } return 1; }



RE: Error: expected expression value - Boop - 07-30-2012

(07-30-2012, 06:41 PM)A-MAN Wrote:  Ok man. As that was suppose convert the bool value inside to int. That code it self got errors:
ai/10.as(2, 5): Error: Expected expression value
ai/10.as(9, 1): Error: Expected expression value

Code:
int ego(){ int tempFacing: if (self.facing) { tempFacing = 1; } else { tempFacing = 0; } int xdist = target.x-self.x; int ydist = target.y-self.y; int zdist = target.z-self.z; int xdista = (target.x-self.x)*(2*tempFacing-1); int random = rand(4); if (zdist >= 5) { up(); }else if (zdist <= -5) { down(); }else if (zdist <= 5) { up(0,0); }else if (zdist >= -5) { down(0,0); } if (zdist >= 5 && zdist <= -5 && xdista <= 45) { DuJ(); } return 1; }

....

int tempFacing; not :

Code:
int ego(){ int tempFacing; if (self.facing) { tempFacing = 1; } else { tempFacing = 0; } int xdist = target.x-self.x; int ydist = target.y-self.y; int zdist = target.z-self.z; int xdista = (target.x-self.x)*(2*tempFacing-1); int random = rand(4); if (zdist >= 5) { up(); } else if (zdist <= -5) { down(); } else if (zdist <= 5) { up(0,0); } else if (zdist >= -5) { down(0,0); } if (zdist >= 5 && zdist <= -5 && xdista <= 45) { DuJ(); } return 1; }