Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   If you could change one thing about GScript, what would it be? (https://forums.graalonline.com/forums/showthread.php?t=134263610)

cbk1994 06-20-2011 08:30 AM

If you could change one thing about GScript, what would it be?
 
If you could go back in time before GS2 and change any one thing about it, what would it be? Compatibility with old code is not a problem—even a change as drastic as strict typing is acceptable for this exercise. Ideally they will be entirely language-related and not things such as documentation, version control, etc.

My one thing:
I would make objects use a strict class system, and make it easy for scripters to edit these object classes. There would be a list of scripts much like the NPCs list for object classes (not related to classes now). These classes would have constructors, and support inheritance. All object types (such as GuiScrollCtrl) would work in this fashion (although they would not appear in this class list) and could be extended by objects. I could make a class called GuiIPhoneScrollCtrl which extends GuiScrollCtrl and has iPhone-like scrolling.

fowlplay4 06-20-2011 03:03 PM

Remove the need for temp prefixing.

Crow 06-20-2011 03:25 PM

Quote:

Originally Posted by fowlplay4 (Post 1655482)
Remove the need for temp prefixing.

I'm just curious: What would you prefer instead? No prefixes for temporary vars at all, instead using constructors for global vars?

fowlplay4 06-20-2011 03:41 PM

Quote:

Originally Posted by Crow (Post 1655483)
I'm just curious: What would you prefer instead? No prefixes for temporary vars at all, instead using constructors for global vars?

Yeah something like that, and maybe a global prefix.

This would be my target result:

PHP Code:

function onCreated() {
  
1;
  
2;
  
otherFunc();
  echo(
a SPC b); // with change it echos "1 2" currently it echos "2 1"
}

function 
otherFunc() {
  
2;
  
1;



WhiteDragon 06-21-2011 07:01 AM

Make it based on a dependent type theory.

More realistically: make it much, much closer to JavaScript. Essentially, ECMAScript with a DOM-like interface to Graal.

Mark Sir Link 06-21-2011 08:25 PM

ability to restrict query execution/variable changes to certain classes/weapons/NPCs

smirt362 06-22-2011 05:50 AM

The lack of masking support
http://forums.graalonline.com/forums...hp?t=134263607

Twinny 06-22-2011 01:10 PM

Quote:

Originally Posted by Mark Sir Link (Post 1655650)
ability to restrict query execution/variable changes to certain classes/weapons/NPCs

Been requested so many times...can only hope!

Mark Sir Link 06-22-2011 08:41 PM

Quote:

Originally Posted by Twinny (Post 1655769)
Been requested so many times...can only hope!

http://forums.graalonline.com/forums...hp?t=134260502

MrDunne 07-01-2011 01:00 AM

Fix anonymous functions.

Chompy 07-01-2011 01:20 AM

Quote:

Originally Posted by MrDunne (Post 1656878)
Fix anonymous functions.

Elaborate.

WhiteDragon 07-01-2011 02:05 AM

Quote:

Originally Posted by Chompy (Post 1656880)
Elaborate.

There are a few problems.
  • In certain cases, when passing around an anonymous function, you lose the ability to call it. I think the problem is when you call the anonymous function from a different class than it was defined, but I'm not certain exactly when it happens. (If someone wants to debug this, please do.)

    My current hack around this is, given a function temp.f, doing (@temp.f)(), which casts the function pointer to a string like "function_913727", which is a global variable and can be called from anywhere as a result.
  • When a class using anonymous functions is updated, most things break until you update the NPC/Weapon that they are joined to.

MrDunne 07-01-2011 09:22 AM

Quote:

Originally Posted by Chompy (Post 1656880)
Elaborate.

Quote:

Originally Posted by WhiteDragon (Post 1656885)
There are a few problems.
  • In certain cases, when passing around an anonymous function, you lose the ability to call it. I think the problem is when you call the anonymous function from a different class than it was defined, but I'm not certain exactly when it happens. (If someone wants to debug this, please do.)

    My current hack around this is, given a function temp.f, doing (@temp.f)(), which casts the function pointer to a string like "function_913727", which is a global variable and can be called from anywhere as a result.
  • When a class using anonymous functions is updated, most things break until you update the NPC/Weapon that they are joined to.

Mainly this. There's also this:

PHP Code:

function onCreated() {
  
temp.func myTest();
  (@ 
temp.func)();

  
myOtherTest(function () {
    echo(
"yeah baby");
  });
}

function 
myTest() {
  return function () {
    echo(
"yeah baby");
  };
}

function 
myOtherTest(func) {
  (@ 
func)();


Produces the following:

HTML Code:

Script compiler output for *scratch*:
error: unexpected token: function at line 3: myOtherTest(function () {
error: unexpected token: ( at line 3: myOtherTest(function () {
error: unexpected token: ) at line 3: myOtherTest(function () {
error: unexpected token: ) at line 5: });
error: unexpected token: function at line 13: return function () {
error: unexpected token: ( at line 13: return function () {
error: unexpected token: ) at line 13: return function () {

It doesn't seem right to me.

WhiteDragon 07-01-2011 09:42 AM

Quote:

Originally Posted by MrDunne (Post 1656905)
There's also this: ...

That's a result of the GS2 grammar not being flexible enough. Ideally, anonymous functions would be listed as expressions (so you could put them anywhere you could put, say, true), but they seem to only be allowed in variable assignments (i.e., temp.f = ...).

One nifty hack around this one is, for example, return (temp.f = function () { ... } );. But that's rather ugly and I certainly don't do it :p.

But yeah, that is indeed another thing that should be changed and should be fairly straightforward.

MrDunne 07-01-2011 01:17 PM

Quote:

Originally Posted by cbk1994 (Post 1655466)
I would make objects use a strict class system, and make it easy for scripters to edit these object classes. There would be a list of scripts much like the NPCs list for object classes (not related to classes now). These classes would have constructors, and support inheritance. All object types (such as GuiScrollCtrl) would work in this fashion (although they would not appear in this class list) and could be extended by objects. I could make a class called GuiIPhoneScrollCtrl which extends GuiScrollCtrl and has iPhone-like scrolling.

I kinda disagree here. I think pushing GS's object system more towards Javascript and prototypical OO would be far better. I think it'd be way easier going in that direction than going back and redoing it in a different style of OO.


All times are GMT +2. The time now is 09:16 AM.

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