Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   Announcements (https://forums.graalonline.com/forums/forumdisplay.php?f=240)
-   -   Gs3 (https://forums.graalonline.com/forums/showthread.php?t=134268072)

Admins 04-12-2013 03:24 PM

Gs3
 
Hello Graalians,

We have just started the work on a new scripting project and want your ideas and feedback about it. The idea is to create new Graal Script version (GS3) which will make scripts faster and more fit for bigger projects.

The idea

We plan to introduce 'types' to Graal script. This first means some more work for scripters but it also has some dramatic advantages:
- Scripts can run faster
- More reliable because it will complain when a variable has not been declared or is used incorrectly. This is important when doing bigger projects.
- We can possibly convert the scripts to other languages (C++, Javascript etc.) so it can possibly run in a browser in the future
- Code will be more readable, you don't have to guess what kind of variables need to be passed to a function or is returned by a function

The progress

We are already working on a converter which helps to convert scripts from GS2 to GS3. So a lot of work will be lifted from the programmer, and you can also use this tool for testing how the new scripting will look like.
Additional following things can be important to know:
- existing scripts will still run, we don't force the new syntax and semantic, but it can be interesting for server-side logic and also new client-side code
- just add a //#GS3 line to your script to use the new syntax and semantic
- some syntax of the new Graal script is already supported but currently ignored (like var statements)

Examples

Functions:
Old:
PHP Code:

function getAddition(ab) {
  
temp.result b;
  return 
temp.result;


New:
PHP Code:

function getAddition(a:numberb:number):number {
  var 
result:number b;
  return 
result;


Gui:
Old:
PHP Code:

new GuiControlProfile("Games_Msg_BackProfile") {
  
modal false;


New:
PHP Code:

var profile:GuiControlProfile = new GuiControlProfile("Games_Msg_BackProfile");
profile.modal false

Type declarations:
Old:
PHP Code:

function saveOptions() {
  
temp.options.age 24;
  
temp.options.gender "female";
  
temp.options.city "Dallas";
  
temp.options.savevars("options.txt"0);


New:
PHP Code:

class Options extends TGraalVar {
  var 
age int;
  var 
gender string;
  var 
city string;
}
function 
saveOptions():void {
  var 
options:Options = new Options();
  
options.age 24;
  
options.gender "female";
  
options.city "Dallas";
  
options.savevars("options.txt"0);


What is changing

- You need to declare the type of variables: var myvar: int;
Available types: string, boolean, int, number, void, type[] (for arrays), dictionary<string, int>
- Use "var" declarations instead of temp.
- You can also declare variables of a weapon or NPC at the beginning of the script using var myvar: type;
- The "with" statement is removed and the "new" statement is single-line, you need to call addcontrol() manually
- The dictionary type is needed if you want to access variables with dynamic variable name like this.mydictionary.("start" @ 1)
- Flexible number of function parameters can be done using function(first:int, ... params) (params is a dictionary)
- Global variables can only be accessed directly if you provide a global declaration or if you use findobject("objectname")
- You need to call this.myfunction() instead of myfunction()
- join() works more like an include in C++, there is no this.join anymore
- You can declare new classes (also called structures, types) inline like class MyClass extend TStaticVar; weapons are automatically extending TServerWeapon, NPCs are automatically extending TServerNPC
- The for (member: array) syntax needs to be changed to for (member in array)

Your ideas

As you can see the new Graal script is basically adding type declarations and changing a few smaller things to be more compatible with other languages. Please tell us if you like the new scripting or not, and if you have some stuff which you would like to see in the new scripting language, such as private variables or getter and setter functions. We have just started the project so everything is still possible. We can imagine there are a lot of questions regarding compatiblity and similar.

Hezzy002 04-12-2013 03:49 PM

Why don't you use a popular scripting language like Lua, because there's a massive library of documentation and tutorials for it, and a massive group of people who actually know it already? And LuaJIT is way faster than anything you can develop in-house.

There are also dozens of things that should be a higher priority than this.

Crono 04-12-2013 03:49 PM

will players notice a difference? do you think we'll see new features thanks to this upgrade? :}

Crow 04-12-2013 04:24 PM

Your type syntax looks awful, I wouldn't ever want to use that. Also, one major good point about scripting languages is the lack of type definitions, at least in my opinion. Go with Hezzy's suggestions, use Lua, Python or something similar. Some types of calculations done in Lua can even be as fast as pure C code, or so I've heard.

Gos_pira 04-12-2013 04:47 PM

The C# syntax is nice. I never liked the LUA syntax. I'm for defining variable types and have a more object oriented language though. :)

Crow 04-12-2013 05:08 PM

Quote:

Originally Posted by Gos_pira (Post 1716082)
The C# syntax is nice. I never liked the LUA syntax. I'm for defining variable types and have a more object oriented language though. :)

Please, Lua. Not LUA. D:

Emera 04-12-2013 05:26 PM

I'm not learning another language when the language you have right now can more or less be edited and given just about whatever functionality you want. Why make the community learn a new syntax, especially when the scripting community on here isn't very big.

Crow 04-12-2013 06:19 PM

Because a syntax isn't difficult to learn, especially not Lua's.

smirt362 04-12-2013 06:31 PM

Masking support. Lets get some classic SNES effects on Graal. I still want to make some crazy stuff.

http://i.imgur.com/EB4zAQc.png

Will we also be getting a new Gani and Level editor as well?

DustyPorViva 04-12-2013 06:51 PM

Is this really the best time to do this? Development on Graal is dwindling; there's hardly any scripters left. Do you really want to potentially isolate the few scripters left? GS2 was never documented that well, especially when new things were added. I still have to hunt around the forums looking for anything added in the last couple of years because it's not documented anywhere else. GS1 isn't properly phased out still, yet many people still use it in levels because we still don't have any updated tools. And with Testbed gone there's not even a place available to practice scripting.

edit: I guess since it isn't mandatory it isn't that bad... but I also imagine it's not going to be widely used either. Going to be honest, you're probably going to be the only person using it. I can't say I like the declaration syntax either.

scriptless 04-12-2013 07:32 PM

First, are servers currently updated to support this?

I notice some things in the new GS3 that I catch myself trying to do in GS2.. so I am glad to see these changes.

Quote:

Originally Posted by smirt362 (Post 1716089)
Masking support. Lets get some classic SNES effects on Graal. I still want to make some crazy stuff.

http://i.imgur.com/EB4zAQc.png

Will we also be getting a new Gani and Level editor as well?

Oh, I would love masking support... that would be awesome..

Quote:

Originally Posted by DustyPorViva (Post 1716094)
Is this really the best time to do this? Development on Graal is dwindling; there's hardly any scripters left. Do you really want to potentially isolate the few scripters left? GS2 was never documented that well, especially when new things were added. I still have to hunt around the forums looking for anything added in the last couple of years because it's not documented anywhere else. GS1 isn't properly phased out still, yet many people still use it in levels because we still don't have any updated tools. And with Testbed gone there's not even a place available to practice scripting.

edit: I guess since it isn't mandatory it isn't that bad... but I also imagine it's not going to be widely used either. Going to be honest, you're probably going to be the only person using it. I can't say I like the declaration syntax either.

Yeah but unfortunately us Mac OS X 10.6 users have no level editor, and using macports with gonstruct seemed to get me no where at all. So I can't even develop levels right now due to the lack of tools. There really needs to be an SDK kit..

BlueMelon 04-12-2013 07:33 PM

I develop on graal for the simplicity of the scripting language that is used...

This type of syntax would not fit well with graal scripters/developers introducing types makes it look more like you're building software. What I like about GS2 is the use of temp. this. thiso, etc.

Lua on the other hand is fast/flexible. Lua is a great language.

callimuc 04-12-2013 08:30 PM

you should introduce it on one server which could be set up like testbed, but supported by you/graal. it also should be well documented so people could try it out and feedback could be given

scriptless 04-12-2013 08:36 PM

Quote:

Originally Posted by BlueMelon (Post 1716097)
I develop on graal for the simplicity of the scripting language that is used...

This type of syntax would not fit well with graal scripters/developers introducing types makes it look more like you're building software. What I like about GS2 is the use of temp. this. thiso, etc.

Lua on the other hand is fast/flexible. Lua is a great language.

Thats the only thing I do not like. I do not want to have to declare the type before assigning it. Thats what made graal so fun to develop for (for me).. But the example for how he did the GUI and assigned the modal, is exactly how my instinct tries to do.. if i assign something to an object. i want to be able to change it that way. =/

dylan 04-12-2013 08:54 PM

Aren't you a little late on April Fools? It's the twelfth. :[


All times are GMT +2. The time now is 06:37 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.