Quote:
Originally Posted by fowlplay4
It'd be cool if we could do something like..
PHP Code:
function onCreated() { TServerPlayer.test = function () { echo(this.account); }; for (a: allplayers) a.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(pattern, replacement) {
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).