Page 1 of 2

Script Editor won't accept Code cause "Illegal Syntax"

PostPosted: Fri May 29, 2015 2:43 pm
by Turon
So I'm busy putting a new Octopus Together and the movements will play out in State Method only problem the code wasn't accepted and I have no way of verifying why as I have declared all the variables and checked the code repeatedly....
Code: Select all
switch(STATE)
{
    case 0:
    ChangeAnimation("Event Actor", "StillLeft", NO_CHANGE);
    STATE=1;
    break;
 
    case 1:
    ChangeAnimation("Event Actor", "MoveLeft", NO_CHANGE);
    STATE=3;
    break;
 
    case 2:
    ChangeAnimation("Event Actor". "StillLeft", NO_CHANGE);
    STATE=1;
    break;
 
    case 3:
    break;
 
    case 4:
    ChangeAnimation("Event Actor", "JumpLeft", NO_CHANGE);
    STATE=5;
    break;
 
    case 5:
    break;
 
    case 6:
    ChangeAnimation("Event Actor", "FallLeft", NO_CHANGE);
    STATE=7;
    break;
 
    case 7:
    break;
}
x-=2;

Re: Script Editor won't accept Code cause "Illegal Syntax"

PostPosted: Fri May 29, 2015 8:42 pm
by lcl
And STATE is an Integer variable, right?

Re: Script Editor won't accept Code cause "Illegal Syntax"

PostPosted: Fri May 29, 2015 9:50 pm
by Turon
An Integer is a counting number or a cardinal number right? But how is that related to the problem?

Re: Script Editor won't accept Code cause "Illegal Syntax"

PostPosted: Sat May 30, 2015 12:26 am
by speckford123
Turon wrote:An Integer is a counting number or a cardinal number right? But how is that related to the problem?


The switch code will only accept integers, if it's a real or string variable it fails
is it a predefined user variable in your script editor?

Re: Script Editor won't accept Code cause "Illegal Syntax"

PostPosted: Sat May 30, 2015 8:51 am
by Turon
All of the values in my code look like integer numbers to me... What are string variables again? I'm a little rusty...

Re: Script Editor won't accept Code cause "Illegal Syntax"

PostPosted: Sat May 30, 2015 10:22 am
by digiot
Since you are using capital letters for those "suspected variables",
my suspicion is, that you are trying to alter constants, what is not
working by design.

Re: Script Editor won't accept Code cause "Illegal Syntax"

PostPosted: Sat May 30, 2015 11:30 am
by Turon
Um, what's a constant?

Re: Script Editor won't accept Code cause "Illegal Syntax"

PostPosted: Sat May 30, 2015 2:52 pm
by digiot
Turon wrote:Um, what's a constant?

Variables, constants, char(acter)s, what they all
have in common, is: Nomen est omen !

And variables (numbers) can have several types, like integers and floats,
which are classifying their scope.

For a deeper insight, take a C tutorial of your choice !

And let us see, how you declared "STATE" !


Cheers !

Re: Script Editor won't accept Code cause "Illegal Syntax"

PostPosted: Sat May 30, 2015 8:47 pm
by Turon
I defined STATE like I do with all variables, I learned I think from this Krennisis Tutorial: viewtopic.php?f=4&t=8603&start=0 (seriously why was he banned?)

Re: Script Editor won't accept Code cause "Illegal Syntax"

PostPosted: Sat May 30, 2015 9:33 pm
by digiot
Sorry, Turon, it's still unclear for me, how you declare variables (and constants).
I guess, you are using the variable adding dialog inside the global code editor.
That way has pros and cons, but at least, you can't define constants accidentally.

To find the error, GEs compiler is complaining about, we need the Ged !

Re: Script Editor won't accept Code cause "Illegal Syntax"

PostPosted: Sun May 31, 2015 6:05 pm
by Turon
You need the ged.? Okay I got it here...

Re: Script Editor won't accept Code cause "Illegal Syntax"

PostPosted: Sun May 31, 2015 6:29 pm
by lcl
Your code has a '.' in some of the ChangeAnimation -calls where there should be a ','. 8)

Re: Script Editor won't accept Code cause "Illegal Syntax"

PostPosted: Sun May 31, 2015 7:37 pm
by Turon
Darn how did that pass my eye unnoticed? Well I guess I don't have the best eyes and the script editor's colors kind of suck...
I couldn't copy and past so I had to type it over again...

Re: Script Editor won't accept Code cause "Illegal Syntax"

PostPosted: Sun May 31, 2015 8:10 pm
by lcl
Turon wrote:Darn how did that pass my eye unnoticed? Well I guess I don't have the best eyes and the script editor's colors kind of suck...
I couldn't copy and past so I had to type it over again...

Well, by only looking at the code it's very easy to miss small things like that. But that's why the error messages exist. The error message was the thing that made me find the mistake. The messages always try to tell what GE thinks is wrong with the code, and they also provide the number of the line where the error is. Current line number is shown in the upper right corner of the script editor, so using that it's usually easy to locate the error from the code according to the number of the line where the error is.

Of course, there are some errors that make GE "confused" and at those times the approximated line number for the error can be something ridiculous, like 2401 even if there's only 20 lines of code. But usually the error messages are very helpful. :)

Re: Script Editor won't accept Code cause "Illegal Syntax"

PostPosted: Mon Jun 01, 2015 9:57 am
by Turon
Thank You so much lcl :D! you certainly have an eye for small details (or maybe I'm just rusty), but what is for sure I would have still been in the dark if that problem was not rectified... I was very carefull typing that down but this experience has taught me to be even more careful :mrgreen: .