PDA

View Full Version : GS3 conversion tool (Updatedx2)


Admins
06-16-2013, 02:59 PM
We have worked on a tool for converting GraalScript2 to the new Graalscript3 syntax:

http://graalscript3.graalonline.com/

You can use it to test a little bit and see how the new scripting will look like. We plan to release GS3 officially in a few weeks, after improving compatibility and features.

Edit: Updated on June 21 to add better support for global functions and types! You have to restart the npcserver.
Edit: Updated on June 24 to fix object attributes like player.account (TServerPlayer.account), no additional restart required.

Chompy
06-16-2013, 03:19 PM
//#CLIENTSIDE
function onCreated() {
this.speed = 1;
}

function onTimeout() {
player.x += (keydown(3)-keydown(1))*this.speed;
player.y += (keydown(2)-keydown(0))*this.speed;
setTimer(0.05*this.on);
}

function onKeyPressed(code, key) {
this.on = abs(this.on-(key=="b"));
setTimer(0.05*this.on);
}
function onPlayerChats() {
if (player.chat.starts("/speed ") && this.on) {
this.speed = int(player.chat.substring(7));
}
}


Tested this staff boots script, just to see how it works, and it gave this error in the onPlayerChats() event, right under the if statement: Unexpected symbol 'if'

But apart from that, looking good!

BlueMelon
06-16-2013, 04:01 PM
Fails to convert a 50 line script when I tried..
(No error just stays at "Converting..." forevor)

Chompy
06-16-2013, 04:29 PM
Fails to convert a 50 line script when I tried..
(No error just stays at "Converting..." forevor)

I think posting the script could help with debugging it and to find a solution :)

scriptless
06-16-2013, 05:34 PM
Sweet. Looking forward to an official release.

Julien
06-17-2013, 02:50 PM
//#CLIENTSIDE
function onCreated() {
this.speed = 1;
}

function onTimeout() {
player.x += (keydown(3)-keydown(1))*this.speed;
player.y += (keydown(2)-keydown(0))*this.speed;
setTimer(0.05*this.on);
}

function onKeyPressed(code, key) {
this.on = abs(this.on-(key=="b"));
setTimer(0.05*this.on);
}
function onPlayerChats() {
if (player.chat.starts("/speed ") && this.on) {
this.speed = int(player.chat.substring(7));
}
}


Tested this staff boots script, just to see how it works, and it gave this error in the onPlayerChats() event, right under the if statement: Unexpected symbol 'if'

But apart from that, looking good!

There was a problem with the '&' and '&&' operators.
It's fixed now.
Your script is reporting more meaningful errors.

Please note that built-in global functions are only partially supported:
"keydown" and "setTimer" are still being reported as not existing functions.

Draenin
06-17-2013, 03:33 PM
It'd be nice if this were integrated into RC, and not a web page that people have to find via the forums. (Most likely months later.)

scriptless
06-17-2013, 04:57 PM
It'd be nice if this were integrated into RC, and not a web page that people have to find via the forums. (Most likely months later.)

They probably wont even know it's enabled until they see the thread tho.. lol

fowlplay4
06-17-2013, 06:15 PM
There was a problem with the '&' and '&&' operators.
It's fixed now.
Your script is reporting more meaningful errors.

Please note that built-in global functions are only partially supported:
"keydown" and "setTimer" are still being reported as not existing functions.

look guys its either an intern or paid eurocenter employee!

Dragon551
06-17-2013, 07:27 PM
look guys its either an intern or paid eurocenter employee!

He's watching us..

Cubical
06-17-2013, 09:28 PM
look guys its either an intern or paid eurocenter employee!

dont be silly, its ravej's troll account where he actually uses spell check

callimuc
06-17-2013, 09:39 PM
There was a problem with the '&' and '&&' operators.
It's fixed now.
Your script is reporting more meaningful errors.

Please note that built-in global functions are only partially supported:
"keydown" and "setTimer" are still being reported as not existing functions.

OMG HAII!!! Enjoy your stay

Gunderak
06-19-2013, 09:43 AM
Failed completely :/

public function NewRC(acc){
//Let NC messages send first..
sleep(5);
temp.comment = this.GetComments(acc);
if(md5(comment) != this.(@acc)){
acc.sendtorc("Your comments have changed since you last logged on.");
}
this.(@acc) = md5(comment);
}
function GetComments(ac){
temp.st = temp.ac.substring(0, 2);
temp.path = format("accounts/%s/%s.txt", st, ac);
temp.file.loadstring(temp.path);
temp.file = temp.file.tokenize("\r\n");
temp.comments;
for(temp.line : temp.file){
if(line.starts("COMMENTS")){
return line.substring(9);
}
}
return "none";
}

Julien
06-19-2013, 10:15 AM
Failed completely :/

public function NewRC(acc){
//Let NC messages send first..
sleep(5);
temp.comment = this.GetComments(acc);
if(md5(comment) != this.(@acc)){
acc.sendtorc("Your comments have changed since you last logged on.");
}
this.(@acc) = md5(comment);
}
function GetComments(ac){
temp.st = temp.ac.substring(0, 2);
temp.path = format("accounts/%s/%s.txt", st, ac);
temp.file.loadstring(temp.path);
temp.file = temp.file.tokenize("\r\n");
temp.comments;
for(temp.line : temp.file){
if(line.starts("COMMENTS")){
return line.substring(9);
}
}
return "none";
}


Hello,

After trying the above code on http://graalscript3.graalonline.com/, it reports successful conversion.
The conversion is not really perfect though. For example, the converter tool cannot guess the type of the "acc" parameter in the "NewRC" function.

When checking syntax, several errors are reported.
Some errors are valid, others are not (for example "md5" function is not supported yet).

Could you please detail what is going wrong on your side?
Do you have any error reported? Is the conversion running forever maybe?

Gunderak
06-19-2013, 10:38 AM
No, it converts it with errors.
The main problem is the md5, the rest I could convert myself, and did.
How would I reference md5?
It would be cool if we could do something like global::md5() or using namespace global;

Julien
06-19-2013, 11:09 AM
No, it converts it with errors.
The main problem is the md5, the rest I could convert myself, and did.
How would I reference md5?
It would be cool if we could do something like global::md5() or using namespace global;

OK, fine.
The converter is more an helper tool to learn and play with the GS3 syntax. It automatically converts scripts but only to some extent.

If you want to improve the conversion, you can annotate types like for example the "acc" parameter.
Then, you iterate:

Launch the conversion
Check the syntax
Annotate missing types
etc...


In order to reference missing global functions, you can use extern declarations.

Example:

extern global {
function md4(text : string) : string;
}

function onCreated() : void {
var result : string = md4("hello world");
}


Note: "md5" was added in the meantime.

Gunderak
06-21-2013, 11:54 AM
In order to reference missing global functions, you can use extern declarations.

Example:

extern global {
function md4(text : string) : string;
}

function onCreated() : void {
var result : string = md4("hello world");
}


Note: "md5" was added in the meantime.
Nope, doesn't work.

Julien
06-21-2013, 03:25 PM
The "md4" function does not exist, this was just to provide you with an example of how to declare extern global functions.
This code is valid and should not produce any errors when converting or checking syntax online, or when compiling on GS3-enabled NPC servers.

In the meantime, all client-side and server-side global functions and classes are now available for the online conversion tool (including md5 et al.).

If you add //#CLIENTSIDE, you can actually test at the same time the server-side and client-side conversion / syntax.

Admins
06-21-2013, 05:08 PM
We have updated the conversion tool and also updated the //#GS3 support on servers but you need to restart the npcserver.

Like Julien said, it's now correctly reporting global functions and types and also supports //#CLIENTSIDE (some functions only exist on server-side or client-side). It also prints some more warnings and fixes some bugs (arrays etc.), improving the support for inline-classes.

If you have any ideas or comments then please let us know :)

scriptless
06-21-2013, 06:19 PM
//#GS3 support on servers but you need to restart the npcserver.


So does this mean it's officially released? And is that all dev servers as-well?

Gunderak
06-22-2013, 03:18 AM
Julien, I know md4 doesn't exist in Graal, I tried it with md5, my whole point is, how the hell do you call methods like md5. It just errors that it doesn't exist.

Admins
06-22-2013, 05:01 PM
The latest version has been uploaded yesterday to all machines but you might need to restart the npcserver. Normally all global functions should work fine now. There are still some errors though (player.account shows an error), and you are welcome to report problems. We hope to soon use it for important scripts though, like for the iPhone servers.

scriptless
06-22-2013, 08:53 PM
The latest version has been uploaded yesterday to all machines but you might need to restart the npcserver.

When I tried using GS3 it said it was not enabled. I had to add the following line to the sever options to work:

enablegs3=true

To anyone who is curious you need to add that flag, as well as restart your server. And to use GS3 just add //#GS3 to the top of the script.

Admins
06-22-2013, 10:48 PM
Yes follow the instructions at
http://wiki.graal.net/index.php/Creation/Dev/GScript3

Admins
06-24-2013, 10:40 AM
We have fixed object attributes like player.account (TServerPlayer.account), no additional restart required.

Crono
06-24-2013, 10:41 AM
graal, using hashtags since npc-server was released :cool:

//#CLIENTSIDE //#YOLO

Fulg0reSama
06-24-2013, 11:43 AM
graal, using hashtags since npc-server was released :cool:

//#clientside //#yolo


//#yolo
//#swag

BlueMelon
06-24-2013, 12:51 PM
//#yolo
//#swag


It is necessary for us on Era to include this in our scripts,
else we're going to have a bad time

Tavelate
06-27-2013, 11:54 PM
It is necessary for us on Era to include this in our scripts,
else we're going to have a bad time

I feel outstandingly fortunate not being part of that community.

Fulg0reSama
06-28-2013, 04:36 AM
I feel outstandingly fortunate not being part of that community.

http://upload.wikimedia.org/wikipedia/commons/7/7e/Thumbs-up-icon.png