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)

fowlplay4 04-12-2013 08:56 PM

Personally prefer the Java-style of declaring variables/types than your current GS3 way, no need to carry over how we currently use temp to GS3 as it just adds unnecessary code.

type variable;

Being able to create global functions would be cool too, I imagine GS3 would be more flexible in some way that we can modify built-in functions?

I.e.

PHP Code:

class Options extends TGraalVar 
  
int age;
  
string gender;
  
string city;
}

function 
void saveOptions() { 
  
Options options = new Options(); 
  
options.age 24
  
options.gender "female"
  
options.city "Dallas"
  
options.savevars("options.txt"0); 
}

function 
number addNumbers(number anumber b) {
  return 
b;



MattKan 04-12-2013 09:35 PM

Are there any benefits to adopting GS3 or is just change for the sake of change?

DustyPorViva 04-12-2013 09:39 PM

Quote:

Originally Posted by fowlplay4 (Post 1716101)
Personally prefer the Java-style of declaring variables/types

Ditto, but I felt biased saying that since I only know Java.

scriptless 04-12-2013 09:54 PM

Quote:

Originally Posted by MattKan (Post 1716103)
Are there any benefits to adopting GS3 or is just change for the sake of change?

Yes.

Quote:

Originally Posted by Stefan (Post 1716075)
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


fowlplay4 04-12-2013 10:07 PM

Quote:

Originally Posted by MattKan (Post 1716103)
Are there any benefits to adopting GS3 or is just change for the sake of change?

According to Stefan: Faster, will run better on other platforms, forcing people to declare variables/types will make code more self-documenting (You can see that in the options example) and also more stricter so perhaps stuff won't break as easy.

Cubical 04-13-2013 12:08 AM

I would also prefer something similar to java like jerrets example. But just like dusty I am biased because I frequently use java.

fowlplay4 04-13-2013 01:14 AM

Also curious how this would look like in GS3.

Weapon: Example

PHP Code:

function onActionServerSide() {
  if (
params[0] == "hello") {
    
player.triggerclient("weapon"this.name"goodbye");
  }
}

//#CLIENTSIDE

function onCreated() {
  
triggerserver("gui"this.name"hello");
}

function 
onActionClientSide() {
  if (
params[0] == "goodbye") {
    
player.chat "*fistbump*";
  }


Also if there's no 'with' (I still think there should be) how would this work out:

Weapon: GUIExample

PHP Code:

//#CLIENTSIDE
function onCreated() {
  new 
GuiWindowCtrl("Example") {
    
profile GuiBlueButtonProfile;
    
width height 100;
    new 
GuiButtonCtrl("ButtonExample") {
      
profile GuiBlueButtonProfile;
      
width height 10;
    }
    new 
GuiButtonCtrl("ButtonExample2") {
      
profile GuiBlueButtonProfile;
      
width height 30;
    }  
  }



Admins 04-13-2013 02:26 AM

PHP Code:

function onActionServerSide(action:string):void {
  if (
action == "hello")
    
player.triggerclient("weapon"this.name"goodbye");
}

//#CLIENTSIDE

function onCreated():void {
  
triggerserver("gui"this.name"hello");
}

function 
onActionClientSide(action:string) {
  if (
action == "goodbye")
    
player.chat "*fistbump*";


PHP Code:

//#CLIENTSIDE
function onCreated():void {
  var 
window:GuiWindowCtrl = new GuiWindowCtrl("Example");
  
window.profile findobject("GuiBlueButtonProfile");
  
window.window.window.width window.height 100;

  var 
button:GuiButtonCtrl = new GuiButtonCtrl("ButtonExample");
  
button.profile findobject("GuiBlueButtonProfile");
  
button.button.button.width button.height 10;
  
window.addcontrol(button);

  
button = new GuiButtonCtrl("ButtonExample2");
  
button.profile findobject("GuiBlueButtonProfile");
  
button.button.button.width button.height 30;
  
window.addcontrol(button);


The idea with tools is this:
We finish the scripted level editor by combining some of the best scripted/online editors, and convert it to GS3. This can be available online and we are also able to convert it to other scripting languages to import it into other development platforms. So we can also possibly offer new offline editors in the future.

So there are several additional advantages:
Graal script will not be a black box anymore, it will possible to bring it to faster scripting engines and platforms.
It will also be more close to other scripting languages, so you your knowledge will be more interesting for "real life" purposes, and more programmers from outside of Graal could be able to script in GS3. A lot of head-aches with variable lookups and such things are gone.

For script help normally /scripthelp is working quite fine, all new functionality is automatically added to /scripthelp or to the list you get by starting Graal with the "-listscriptfunctions" command-line option. The documentation on wiki.graal.net could be reorganized a little bit after we introduce GS3, although most global functions and GUI objects will be the same.

Gos_pira 04-13-2013 02:57 AM

Quote:

Originally Posted by fowlplay4 (Post 1716101)
Personally prefer the Java-style of declaring variables/types than your current GS3 way, no need to carry over how we currently use temp to GS3 as it just adds unnecessary code.

type variable;

Being able to create global functions would be cool too, I imagine GS3 would be more flexible in some way that we can modify built-in functions?

I.e.

PHP Code:

class Options extends TGraalVar 
  
int age;
  
string gender;
  
string city;
}

function 
void saveOptions() { 
  
Options options = new Options(); 
  
options.age 24
  
options.gender "female"
  
options.city "Dallas"
  
options.savevars("options.txt"0); 
}

function 
number addNumbers(number anumber b) {
  return 
b;



I'd personally prefer:

PHP Code:

public class Options TGraalVar 

  
int age;
  
string gender;
  
string city;
}

public class 
Npc
{
    public 
void saveOptions()
    { 
        
Options options = new Options(); 
        
options.age 24
        
options.gender "female"
        
options.city "Dallas"
        
options.savevars("options.txt"0); 
    }

    public 
float addNumbers(float afloat b)
    {
        return 
b;
    }



cbk1994 04-13-2013 03:30 AM

I like the changes you're considering quite a bit, but the syntax definitely feels clunky. Is there any reason you couldn't just do C-style variable types?

Also, is it necessary to keep "function"? Why not just use the return type:

PHP Code:

// double return value
double mean(double adouble b) {
  return (
b) / 2;
}

// no return value
void log(string message) {
  echo(
message);
}

// returns something, "def" is a type that can hold anything
def anything() {
  
def[] array = [playerthis"a"];
  return array[
int(random(0, array.size()))];


This syntax would be more comfortable for a lot of amateur and professional programmers.

devilsknite1 04-13-2013 03:52 AM

I do not want to reject change just for doing it, but Dusty's post captures my thoughts practically verbatim. I don't mind a new coding language, especially if there will be visible benefits to the game, but I would really like to see thorough documentation on this if other languages like Lua will not be used. It wouldn't be wise to just release it with poor instruction on how the code functions with proper syntax and examples, very much like how GS2 was released. You should be wanting to bring in more coders, not making them know GS2, then go learn other coding fundamentals from other languages (declaring variables, when to use void, etc.), then come back to Graal and implement GS2 and guess at the structure of GS3 using a different syntax knowledge from another language, then have no idea where to proceed since there is no trace of documentation anywhere.

Quote:

Originally Posted by Stefan (Post 1716118)
For script help normally /scripthelp is working quite fine, all new functionality is automatically added to /scripthelp or to the list you get by starting Graal with the "-listscriptfunctions" command-line option.

Back to the not wanting to drive coders away part... That's all fine, except if a new developer wants to jump in on GS3, it's a bit of a jumbled mess with having to know GS2, then scanning and hoping that the proper syntax with examples are listed in /scripthelp. Most of the time it's just command(int, string, string) without any guidance as to what the integer and strings are supposed to be. If that's changed it will help a lot, otherwise you're going to have a lot of wiki editing to do.

My 2 cents, but I think I will stick to GS2 unless GS3 is properly documented. Though, I will say I do think heading in this direction is a good thing. The timing is just a bit off as well as the odd/clunky syntax styles. Just rip off of another language's syntax or use an already existing language fully capable of attracting new developers *cough*Lua*cough*.

Elk 04-13-2013 03:56 AM

So technically you can connect to PC Graal via Browser with a proper Login?

Gos_pira 04-13-2013 04:10 AM

Quote:

Originally Posted by Elk (Post 1716125)
So technically you can connect to PC Graal via Browser with a proper Login?

I think he means that porting scripts between script engines would be easier with these changes. Unless I just misunderstood what you meant.

Gamerkid7 04-13-2013 05:05 AM

I agree with fowlplay4 and Gos_pira. I much prefer a Java-like syntax. The type declarations of the proposed GS3 just looks clunky and is needlessly different than common languages.

One feature that I would love to see is proper closures. Anonymous functions are great but don't maintain any context. This would make utility libraries extremely versatile. For example, a remove_if() method that takes a list and predicate function:

PHP Code:

function void removeIDs(int [B]rem_id[/B]) {
    
remove_if(this.idlist, function bool (int obj_id) {
       if (
obj_id == [B]rem_id[/B])
           return 
true;
       return 
false;
    });
    
UpdateDiplay();  


Then the code for remove_if only has to be maintained in one place and it would be a lot easier to figure out what a piece of code is doing from the functions being called.

DrakilorP2P 04-13-2013 02:41 PM

I think this looks great. I don't mind the syntax since it's basically ActionScript.
I like the types idea and I like the dictionaries since that's the only thing I ever used the dynamic variable names for anyway.
Are you going to get rid of with() completely, or just with gui objects? How can we define particle effects without typing a lot?

My feature request is some way to share code between serverside and clientside without copy-pasting, which I don't think you can do right now. Maybe the join() changes will make that possible?


All times are GMT +2. The time now is 08:48 PM.

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