View Single Post
  #1  
Old 04-06-2011, 05:48 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Function overriding

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(xy) {
    
temp.tile this.level.tiles[xy];

    if (
tile in {123}) {
      return 
0;
    } else if (
tile in {456}) {
      return 
1;
    } 
// etc
  
};

  
onWall = function(xy) {
    return 
tileType(xy) == 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(01).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(01).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.
__________________

Last edited by cbk1994; 04-06-2011 at 06:03 PM..
Reply With Quote