Graal Forums  

Go Back   Graal Forums > Graal V6 forums > Announcements
FAQ Members List Calendar Today's Posts

 
 
Thread Tools Search this Thread Rating: Thread Rating: 10 votes, 4.60 average. Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 04-12-2013, 03:24 PM
Admins Admins is offline
Graal Administration
Join Date: Jan 2000
Location: Admins
Posts: 11,693
Admins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud of
Smile 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.
Reply With Quote
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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