I've brought this up a few times before, but this would be insanely useful and I think it deserves its own thread.
Function overriding would allow you to essentially overwrite default commands.
For example, if you wanted to create your own tileset layout without a custom movement system (syntax up for debate):
PHP Code:
// weapon -Tiles
//#CLIENTSIDE
function onCreated() {
tileType = function(x, y) {
temp.tile = this.level.tiles[x, y];
if (tile in {1, 2, 3}) {
return 0;
} else if (tile in {4, 5, 6}) {
return 1;
} // etc
};
onWall = function(x, y) {
return tileType(x, y) == 7; // just an example
};
}
Extending object prototypes would also be extremely useful. I think the best way to do it would be to have a class with the same name as the object type. This class would then be 'joined' to all of those objects.
A simple example:
PHP Code:
// class TGraalVar
function capitalize() {
return this.value.substring(0, 1).upper() @ this.value.substring(1);
}
Otherwise, you could go the JavaScript route and edit object prototypes
PHP Code:
TGraalVar.prototype.capitalize = function() {
return this.value.substring(0, 1).upper() @ this.value.substring(1);
};
You could then do this:
PHP Code:
temp.str = "hello world!";
echo(str.capitalize()); // echoes "Hello world!"
Ideally all of this would work both serverside and clientside.
I have no idea how hard this would be to implement, but if it's not too difficult, it would be a huge improvement to GScript.