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)

MysticalDragon 05-22-2013 11:38 PM

Its currently enabled on Zone Iphone but not Delteria Iphone. The reason probably is because its half done? It works in NPC Weapons but not classes.

callimuc 05-23-2013 12:51 AM

it is also disabled on Era iPhone

BlueMelon 05-23-2013 01:47 AM

PHP Code:

//#GS3

function onCreated() {
  echo(
getAddition(1,2));
}

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


Works on era, but the class example does not.

Admins 05-23-2013 01:52 AM

We have not enabled it yet on Graal servers. Part of the syntax has already been accepted (but ignored) for a few years.

Twinny 05-23-2013 04:22 AM

Quote:

Originally Posted by BlueMelon (Post 1718214)
PHP Code:

//#GS3

function onCreated() {
  echo(
getAddition(1,2));
}

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


Works on era, but the class example does not.

Guess it's very lenient..i figured it would have kicked up a shitstorm considering you didn't specify a return type for onCreated() (i.e. void)

So how do we go about getting it enabled?

Skyld 06-03-2013 06:23 PM

For what it's worth the V8 NPC-Server prototype that we tested was a much better idea than this. :(

Twinny 06-05-2013 11:39 AM

Quote:

Originally Posted by Skyld (Post 1718776)
For what it's worth the V8 NPC-Server prototype that we tested was a much better idea than this. :(

You should have made it work then >: (

Gunderak 06-16-2013 07:16 AM

Just tested this on Zone, why... It didn't give any error at all.
PHP Code:

  var list:int[];
  list = {
12"Test"}; 

Also curious, why this didn't work.
PHP Code:

//#GS3
class Person extends TStaticVar{
  var 
nickname:string;
}
function 
onCreated():void{
  
//Create an array of type Person
  
var list:Person[];
  
//Create some Person objects.
  
var me:Person = new Person();
  
me.nickname "Nick";
  var 
them:Person = new Person();
  
them.nickname "Someone";
  
//Add them to the list
  
list.add(me);
  list.
add(them);
  
//Echo each Person element in the list
  
for(var someone:Person in list){
    echo(
"Name: "@someone.nickname);
  }


It does nothing, no errors either.

Also will there be constructors?

Sorry for the spam, but will we be able to extend a TSocket :D?

Admins 06-16-2013 01:54 PM

Yes arrays seem to be bugged, we will work on it.

Twinny 06-16-2013 04:58 PM

My desires:

Constructors (being able to overload would also be awesome but perhaps taking it too far)
PHP Code:

class Test {
  var 
myname string;
  var 
myage int;

  function 
Test(mynamestring) {
    
this.myname myname;
  }
  
//Because overloading is fun
  
function Test(myname stringmyage number) {
    
this.myname myname;
    
this.myage myage;
  }

  function 
echoValues() : void {
    
printf("My name is %s and my age is %i"this.myname, (this.myagethis.myage "Unknown"));
  }
}

function 
onCreated() : void {
  var 
TestObj Test = new Test("Twinny"25);
  
TestObj.echoValues(); 

I know getters/setters will be on the way but this just seems more natural.

I added that printf as it will fail since it's not being referenced in that class(see: extern). For this, perhaps being able to simply prepend global. to global functions would be better. On a similar note, i've not tried but i hope we could use something like super.whatever to access base class items we inherited from :o

Gunderak 06-16-2013 11:23 PM

Quote:

Originally Posted by Twinny (Post 1719319)
My desires:

Constructors (being able to overload would also be awesome but perhaps taking it too far)
PHP Code:

class Test {
  var 
myname string;
  var 
myage int;

  function 
Test(mynamestring) {
    
this.myname myname;
  }
  
//Because overloading is fun
  
function Test(myname stringmyage number) {
    
this.myname myname;
    
this.myage myage;
  }

  function 
echoValues() : void {
    
printf("My name is %s and my age is %i"this.myname, (this.myagethis.myage "Unknown"));
  }
}

function 
onCreated() : void {
  var 
TestObj Test = new Test("Twinny"25);
  
TestObj.echoValues(); 

I know getters/setters will be on the way but this just seems more natural.

I added that printf as it will fail since it's not being referenced in that class(see: extern). For this, perhaps being able to simply prepend global. to global functions would be better. On a similar note, i've not tried but i hope we could use something like super.whatever to access base class items we inherited from :o

This.

Gunderak 06-17-2013 07:02 AM

I still hate the whole object:type thing. Would love it if it was more like Java and C#, object something;

Julien 06-17-2013 01:15 PM

Quote:

Originally Posted by Gunderak (Post 1719338)
I still hate the whole object:type thing. Would love it if it was more like Java and C#, object something;

Hello,

By essence, GScript is a scripting language. GScript is more close to JavaScript-like languages, rather than Java or C#.

This type syntax was chose among other language syntaxes, because it is commonly-used to annotate types in ECMAScript-based languages.

For example:

HTML Code:

// ActionScript
function foo(a:int):int {...}

// TypeScript
function foo(a: number): number {...}

// UnityScript
function foo(a : int) : int {...}

// Haxe
function foo(a : Int) : Int {...}

So, when converting from GS2 syntax to GS3 syntax, you just have to add type annotations to the original syntax.

HTML Code:

//#GS2
function foo(a) {...}

//#GS3
function foo(a : int) : int {...}

With a Java or C# syntax, this will require more semantic changes to the language, like removing the "function" keyword.
Also, you lose the ability to easily import scripts from similar languages (ActionScript, JavaScript, UnityScript, TypeScript...).

HTML Code:

// Java or C#.
int foo(int a) {...}


Twinny 06-18-2013 01:58 AM

Encountered some issues with inheritance,

PHP Code:

//#GS3

class BaseClass {
  var 
baseclassvar number 3;
  
  function 
overwriteMe() : string {
    return 
"You shouldn't see me without accessing baseclass";
  }
}

class 
InheritanceTest extends BaseClass {
  function 
overwriteMe() : string {
    return 
"You should see me!";
  }
}

function 
onCreated() : void {
  
//var BaseClassTest : BaseClass = new BaseClass();
  //echo(BaseClassTest.baseclassvar);
  
  
var TestObj InheritanceTest = new InheritanceTest();
  echo(
TestObj.baseclassvar);
  echo(
TestObj.overwriteMe());


would spit out,

PHP Code:

Weapon/GUI-script Twinny/GS3-Inheritance added/updated by Twinny
Script
Couldn't create object: type BaseClass is not existing in function onCreated in script of Twinny/GS3-Inheritance
Script: Function TestObj.overwriteMe not found in function onCreated in script of Twinny/GS3-Inheritance


Next, uncommenting the lines resulted in,

PHP Code:

Weapon/GUI-script Twinny/GS3-Inheritance added/updated by Twinny
Script
Couldn't create object: type BaseClass is not existing in function onCreated in script of Twinny/GS3-Inheritance
Script: Function TestObj.overwriteMe not found in function onCreated in script of Twinny/GS3-Inheritance
0
bytecode:1305: TypeError: Cannot read property '
name' of null
      typeName = stub.name.extends.name;
                                  ^
Will keep running the old NPC script until server restart. 


I was going to try and do a var BaseTestObj : BaseClass = TestObj; but figured it wouldn't get me too far :)

Gunderak 06-18-2013 06:06 AM

The class should extend something , try extends TStaticVar.
It will probably make it singleton but eh as long as you only use it once.
But also GS1-3 not being a proper language, it doesn't act like proper languages.
Oddly playing around, if you create the object, the class can extend it o.0 not the actual class though?
PHP Code:

//#GS3
class Foot extends TStaticVar{
  var 
id:int;
}
class 
Toe extends Foot{
  var 
id:int;
}
function 
onCreated():void{
  var 
Foot:Foot = new Foot();
  var 
toe Toe = new Toe();
  
toe.id 1;
  echo(
toe.id);



Twinny 06-18-2013 10:12 AM

Quote:

Originally Posted by Gunderak (Post 1719376)
The class should extend something , try extends TStaticVar.
It will probably make it singleton but eh as long as you only use it once.
But also GS1-3 not being a proper language, it doesn't act like proper languages.
Oddly playing around, if you create the object, the class can extend it o.0 not the actual class though?
PHP Code:

//#GS3
class Foot extends TStaticVar{
  var 
id:int;
}
class 
Toe extends Foot{
  var 
id:int;
}
function 
onCreated():void{
  var 
Foot:Foot = new Foot();
  var 
toe Toe = new Toe();
  
toe.id 1;
  echo(
toe.id);



And yet,

PHP Code:

class Animal { ... }
class 
Cat extends Animal { ... }
class 
Dog extends Animal { ... }
var 
cat Cat = new Cat();
var 
dog Dog = new Dog();
var 
cat_as_animal Animal =  cat as Animal// OK as the Cat type is a member of the Animal type.
var cat_as_cat Cat cat_as_animal as Cat// OK as the Cat type is a member of the Animal type.
var cat_as_dog Dog cat as Dog// KO as the Cat type is not a member of the Dog type.
var cat_as_animal_as_dog Dog cat_as_animal as Dog// null as the Cat as Animal type is not a member of the Dog type. 


Taken from: http://wiki.graal.net/index.php/Crea...t3#as_operator

It did resolve my query regarding referencing the base class..need to use 'as' operator :)

Gunderak 06-18-2013 11:50 AM

Ahh nice :)

Gos_pira 06-18-2013 12:05 PM

What's the point of extending if you still need to use the "as" expression? Seems rather retarded to me.

It would make sense if you used it in a foreach on an array of objects of different type.

Like:

"foreach (djur as Animal in this.Animals)"

while this.Animals contains Dog, Cat, Parrot etc.

I might just be misunderstanding something here, if so, disregard my post.

Gunderak 06-18-2013 02:06 PM

Foreach, I did for(various item:class_type in array)

Julien 06-19-2013 03:03 PM

Quote:

Originally Posted by Gunderak (Post 1719303)
Also curious, why this didn't work.
PHP Code:

//#GS3
class Person extends TStaticVar{
  var 
nickname:string;
}
function 
onCreated():void{
  
//Create an array of type Person
  
var list:Person[];
  
//Create some Person objects.
  
var me:Person = new Person();
  
me.nickname "Nick";
  var 
them:Person = new Person();
  
them.nickname "Someone";
  
//Add them to the list
  
list.add(me);
  list.
add(them);
  
//Echo each Person element in the list
  
for(var someone:Person in list){
    echo(
"Name: "@someone.nickname);
  }


It does nothing, no errors either.

In the above code, the "list" variable was not initialized. The GS3 compiler currently fails to compile uninitialized variable declarations.

As a workaround, the following code should work:
PHP Code:

//#GS3
class Person extends TStaticVar{
  var 
nickname:string;
}
function 
onCreated():void{
  
//Create an array of type Person
  
var list:Person[] = {}; // Do not forget to initialize.
  //Create some Person objects.
  
var me:Person = new Person();
  
me.nickname "Nick";
  var 
them:Person = new Person();
  
them.nickname "Someone";
  
//Add them to the list
  
list.add(me);
  list.
add(them);
  
//Echo each Person element in the list
  
for(var someone:Person in list){
    echo(
"Name: "@someone.nickname);
  }



Fulg0reSama 06-20-2013 12:07 AM

Quote:

Originally Posted by Julien (Post 1719419)
!

I am ****ing onto you Julien, we know you are one of them!
Also welcome to the community for what time you will be staying.

Crono 06-20-2013 01:41 AM

Quote:

Originally Posted by Fulg0reSama (Post 1719438)
I am ****ing onto you Julien, we know you are one of them!
Also welcome to the community for what time you will be staying.

****ing onto you?

BlueMelon 06-20-2013 03:14 AM

He was onto me the other day, but then I lagged out

Tim_Rocks 06-21-2013 02:00 AM

Are you guys hitting on each other o_O

Cubical 06-21-2013 04:38 PM

Quote:

Originally Posted by wiki.graal.net
So we have a few advantages:

Helps to write code which is more reliable and readable
The structure of objects can be analyzed for automatic script documentation
Dependencies can be analyzed so you can know which scripts access an object or function
We can make scripts running much faster (not right now but in the future
GraalScript3 can be converted to other languages and platforms, we are preparing something interesting for this to show in a few weeks

@Stefan While you're actively reviewing this thread can you elaborate on this and what you're preparing that's interesting?

Twinny 06-24-2013 01:16 AM

Hey Julien/Stefan,

Any update on my class extending problem? http://forums.graalonline.com/forums...9&postcount=90

Also, will overloading functions be supported?

Julien 06-24-2013 08:06 AM

Hello,

GS3 is currently emulating classes using only GS2 features.
While the GS3 syntax already support constructors, getters / setters, inheritance, classes can only be used as containers as for now.

You can only define simple classes with members initialization but functions do not work yet.

Example:
PHP Code:

class Animal extends TStaticVar {
  var 
name string;
  var 
canBreathe boolean true;
}

class 
Dog extends Animal {
  var 
canBark boolean true;
}

function 
onCreated() : void {
  var 
dog Dog = new Dog();
  
dog.name "Woof";
  echo(
dog.canBark); // 1 (true)
  
echo(dog.canBreathe); // 1 (true)



Angel_Light 07-14-2013 02:04 PM

Quote:

Originally Posted by Stefan (Post 1716075)
- We can possibly convert the scripts to other languages (C++, Javascript etc.) so it can possibly run in a browser in the future

I realize that this deals with Graal's actual source code rather graalscript, but does this means it might possible to port graal to other platforms or handhelds, ie. 3DS and Vita?

Admins 07-15-2013 06:09 PM

We also plan to convert the engine to GS3 sometime :) We more look into targeting Javascript and C# though

Gunderak 07-17-2013 07:34 AM

Why C#?

Julien 07-17-2013 03:54 PM

There are several cross-platform game libraries that are based on the Mono / .NET Framework (C#):
  • Unity 3D (also supports JavaScript-like language)
  • Xamarin
  • MonoGame
  • ...

Conversion from GS3 to C# would allow the Graal engine / tools / scripts to be compatible with these libraries, and possibly deploy on new platforms. :cool:

fowlplay4 07-17-2013 05:48 PM

Quote:

Originally Posted by Julien (Post 1720731)
Conversion from GS3 to C# would allow the Graal engine / tools / scripts to be compatible with these libraries, and possibly deploy on new platforms. :cool:

and this benefits Graal and it's developers how?

callimuc 07-17-2013 06:38 PM

Quote:

Originally Posted by fowlplay4 (Post 1720735)
and this benefits Graal and it's developers how?

more stuff to deal with, particles and FB as example

xAndrewx 07-22-2013 07:28 PM

Quote:

Originally Posted by fowlplay4 (Post 1720735)
and this benefits Graal and it's developers how?

it will bring more players to zodiac;)

GodlyAmbitions 07-24-2013 04:21 AM

i hope they really go for C# instead of gs3

Twinny 07-24-2013 05:20 AM

C# will also be useful for me (as it's my language of choice atm :))

Jakov_the_Jakovasaur 02-18-2014 06:30 PM

hello!

lets just hypothesize for one moment that i were to put my scripting abilities towards developing a playerworld which uses gs3, what alternative platforms could i then expect the playerworld to be made available on, and what time frame could i expect this to be within?

alternatively, if i were to develop a playerworld using gs2 instead, is the current pc platform even going to be supported in future?

thank you!

Tim_Rocks 02-18-2014 08:46 PM

Quote:

Originally Posted by Jakov_the_Jakovasaur (Post 1726116)
hello!

lets just hypothesize for one moment that i were to put my scripting abilities towards developing a playerworld which uses gs3, what alternative platforms could i then expect the playerworld to be made available on, and what time frame could i expect this to be within?

alternatively, if i were to develop a playerworld using gs2 instead, is the current pc platform even going to be supported in future?

thank you!

When Timmah from South Park can walk.

Cubical 09-03-2014 04:14 PM

sup bros, gs4.5 comin next week

eidt: i promise

scriptless 09-04-2014 01:53 AM

Is there any updates on this available? I really like the idea of GS3.


All times are GMT +2. The time now is 04:47 AM.

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