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

Non-platform specific questions.

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

Postby Turon » Fri May 29, 2015 2:43 pm

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;
Turon
 
Posts: 862
Joined: Sun Jan 24, 2010 5:23 pm
Score: 32 Give a positive score

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

Postby lcl » Fri May 29, 2015 8:42 pm

And STATE is an Integer variable, right?
User avatar
lcl
 
Posts: 2339
Joined: Thu Mar 25, 2010 5:55 pm
Location: Finland
Score: 276 Give a positive score

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

Postby Turon » Fri May 29, 2015 9:50 pm

An Integer is a counting number or a cardinal number right? But how is that related to the problem?
Turon
 
Posts: 862
Joined: Sun Jan 24, 2010 5:23 pm
Score: 32 Give a positive score

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

Postby speckford123 » Sat May 30, 2015 12:26 am

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?
speckford123
 
Posts: 334
Joined: Fri May 05, 2006 6:33 pm
Score: 49 Give a positive score

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

Postby Turon » Sat May 30, 2015 8:51 am

All of the values in my code look like integer numbers to me... What are string variables again? I'm a little rusty...
Turon
 
Posts: 862
Joined: Sun Jan 24, 2010 5:23 pm
Score: 32 Give a positive score

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

Postby digiot » Sat May 30, 2015 10:22 am

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.
User avatar
digiot
 
Posts: 211
Joined: Sat Mar 17, 2012 2:29 pm
Score: 7 Give a positive score

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

Postby Turon » Sat May 30, 2015 11:30 am

Um, what's a constant?
Turon
 
Posts: 862
Joined: Sun Jan 24, 2010 5:23 pm
Score: 32 Give a positive score

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

Postby digiot » Sat May 30, 2015 2:52 pm

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 !
User avatar
digiot
 
Posts: 211
Joined: Sat Mar 17, 2012 2:29 pm
Score: 7 Give a positive score

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

Postby Turon » Sat May 30, 2015 8:47 pm

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?)
Turon
 
Posts: 862
Joined: Sun Jan 24, 2010 5:23 pm
Score: 32 Give a positive score

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

Postby digiot » Sat May 30, 2015 9:33 pm

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 !
User avatar
digiot
 
Posts: 211
Joined: Sat Mar 17, 2012 2:29 pm
Score: 7 Give a positive score

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

Postby Turon » Sun May 31, 2015 6:05 pm

You need the ged.? Okay I got it here...
Attachments
Octopus Game .zip
(978.19 KiB) Downloaded 166 times
Turon
 
Posts: 862
Joined: Sun Jan 24, 2010 5:23 pm
Score: 32 Give a positive score

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

Postby lcl » Sun May 31, 2015 6:29 pm

Your code has a '.' in some of the ChangeAnimation -calls where there should be a ','. 8)
User avatar
lcl
 
Posts: 2339
Joined: Thu Mar 25, 2010 5:55 pm
Location: Finland
Score: 276 Give a positive score

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

Postby Turon » Sun May 31, 2015 7:37 pm

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...
Turon
 
Posts: 862
Joined: Sun Jan 24, 2010 5:23 pm
Score: 32 Give a positive score

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

Postby lcl » Sun May 31, 2015 8:10 pm

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. :)
User avatar
lcl
 
Posts: 2339
Joined: Thu Mar 25, 2010 5:55 pm
Location: Finland
Score: 276 Give a positive score

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

Postby Turon » Mon Jun 01, 2015 9:57 am

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: .
Turon
 
Posts: 862
Joined: Sun Jan 24, 2010 5:23 pm
Score: 32 Give a positive score

Next

Return to General

Who is online

Users browsing this forum: No registered users and 1 guest

cron