View Single Post
  #5  
Old 03-07-2011, 02:59 AM
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
Quote:
Originally Posted by fowlplay4 View Post
It'd be cool if we could do something like..

PHP Code:
function onCreated() {
  
TServerPlayer.test = function () {
    echo(
this.account);
  };
  for (
aallplayersa.test(); // Result: RC Spammed with Accounts

I guess the above doesn't really apply here but being able to extend functionality of a built-in Graal class/object without joining a class would be cool.
Adding methods to default objects would indeed be great. In JavaScript, you can edit object "prototypes":

PHP Code:
// from http://www.flzone.com/go?7678
String.prototype.replace = function(patternreplacement) {
  return 
this.split(pattern).join(replacement);

Another idea which I think would work better for GScript would be if you could create a class with the name "TServerPlayer" and all TServerPlayer objects would inherit those methods. This can already be done by joining classes to the player, but for stuff like TServerLevel and TGraalVar (for strings) it would be invaluable. I would love to be able to add string.replace(a, b).
__________________
Reply With Quote