squirrel enum

Discuss the new AI features ("NoAI") introduced into OpenTTD 0.7, allowing you to implement custom AIs, and the new Game Scripts available in OpenTTD 1.2 and higher.

Moderator: OpenTTD Developers

Post Reply
SummerBulb
Engineer
Engineer
Posts: 24
Joined: 06 Feb 2010 22:12

squirrel enum

Post by SummerBulb »

Can anyone please tell me why the SQDEV interpreter doesn't like the following code?

Code: Select all

class A{

 enum B { 
 	AVal,
 	  BVal
 	  }

};
The red line is under the B

Thanks.
Yexo
Tycoon
Tycoon
Posts: 3663
Joined: 20 Dec 2007 12:49

Re: squirrel enum

Post by Yexo »

Because that's not valid syntax in squirrel. See http://squirrel-lang.org/doc/squirrel2.html for the language documentation.
SummerBulb
Engineer
Engineer
Posts: 24
Joined: 06 Feb 2010 22:12

Re: squirrel enum

Post by SummerBulb »

Yexo wrote:Because that's not valid syntax in squirrel. See http://squirrel-lang.org/doc/squirrel2.html for the language documentation.
this:

Code: Select all

enum Stuff {
  first, //this will be 0
  second, //this will be 1
  third //this will be 2
}
was taken from that exact page which i've already read. Still, is doesn't work.

Are you refering to this:

Code: Select all

          enumerations := ( ‘id’ '=' Integer | Float | StringLiteral ) [‘,’]
          stat:= 'enum' id '{' enumerations '}'
I'm not sure i understood that. I'll go try it out and be right back.

[edit:]

The last part looks to me like a formal definition of the enum. But that looks just like what i already did.
Last edited by SummerBulb on 17 Feb 2010 15:00, edited 1 time in total.
Yexo
Tycoon
Tycoon
Posts: 3663
Joined: 20 Dec 2007 12:49

Re: squirrel enum

Post by Yexo »

Defining an enum inside a class in not possible in squirrel, I was referring to that. Classes in squirrel are tables with some extra syntactic sugar.
SummerBulb
Engineer
Engineer
Posts: 24
Joined: 06 Feb 2010 22:12

Re: squirrel enum

Post by SummerBulb »

Yexo wrote:Defining an enum inside a class in not possible in squirrel, I was referring to that. Classes in squirrel are tables with some extra syntactic sugar.
so?
how is it done?

this:

Code: Select all

class A{        
};

enum id { 
	A=1,
	B=2
	 };
doesn't work either.
Yexo
Tycoon
Tycoon
Posts: 3663
Joined: 20 Dec 2007 12:49

Re: squirrel enum

Post by Yexo »

SummerBulb wrote:this:

Code: Select all

class A{        
};

enum id { 
	A=1,
	B=2
	 };
doesn't work either.
Squirrel compiles that code without any errors, if SQDev doesn't support it that's a problem in SQDev and should be reported to it's developers, not here.
Blustuff
Engineer
Engineer
Posts: 112
Joined: 21 Aug 2008 09:37
Location: France

Re: squirrel enum

Post by Blustuff »

SQDev doesn't support many of Squirrel 2.2 syntax elements. Default parameters are not supported either.
SummerBulb
Engineer
Engineer
Posts: 24
Joined: 06 Feb 2010 22:12

Re: squirrel enum

Post by SummerBulb »

Ok.

Thanks all.
Post Reply

Return to “OpenTTD AIs and Game Scripts”

Who is online

Users browsing this forum: No registered users and 38 guests