JavaScript, Server Side, New class

Post here your questions about SFS2X. Here we discuss all server-side matters. For client API questions see the dedicated forums.

Moderators: Lapo, Bax

Baiumka
Posts: 3
Joined: 04 Dec 2018, 09:57

JavaScript, Server Side, New class

Postby Baiumka » 04 Dec 2018, 10:04

Hello. I am trying to create my first game and i have a little problem.
On server side extention i am trying to create new class.

Code: Select all

class _Unit {

  constructor(id,user,x,z,type) {
    this.id = id;
   this.user = user;
   this.x = x;
   this.z = z;
   this.type = type;
  }
}


But when i start it, have an error.

Code: Select all

Exception: javax.script.ScriptException
Message: <eval>:7:0 Expected an operand but found class
class _Unit {
^ in <eval> at line number 7 at column number 0
Description: Error while loading Javascript extension


How i can create a new class with JavaScript? Code is true, but have no idea what i must to do?
Please, somebody help me =)

P.S. Sorry for my bad knowlage of English.
User avatar
Lapo
Site Admin
Posts: 20440
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: JavaScript, Server Side, New class

Postby Lapo » 04 Dec 2018, 11:18

Hi,
on the server side we support EcmaScript 5 while the syntax you're trying to use is ES6.

Classes can be created the old fashioned way, by using prototypes.

Hope it helps
Lapo
--
gotoAndPlay()
...addicted to flash games
Baiumka
Posts: 3
Joined: 04 Dec 2018, 09:57

Re: JavaScript, Server Side, New class

Postby Baiumka » 05 Dec 2018, 11:14

Thank you, now it works)
Baiumka
Posts: 3
Joined: 04 Dec 2018, 09:57

Re: JavaScript, Server Side, New class

Postby Baiumka » 05 Dec 2018, 11:38

Lapo wrote:on the server side we support EcmaScript 5


I think itervals and timeouts, also dont works?
User avatar
Lapo
Site Admin
Posts: 20440
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: JavaScript, Server Side, New class

Postby Lapo » 05 Dec 2018, 15:35

Lapo

--

gotoAndPlay()

...addicted to flash games

Return to “SFS2X Questions”

Who is online

Users browsing this forum: No registered users and 20 guests