Quote:
Originally Posted by Programmer
Your argument contained no hint of inheritance at all 
|
Obviously. If you know how to script then you would know how to implement inheritance on your own based on my example.
PHP Code:
// Weapon Script: Objects
public function ColoredRect(objname, nx, ny, nw, nh, cr, cg, cb, ca, cf) {
temp.obj = this.Rect(objname, nx, ny, nw, nh);
obj.color = this.Color(null, cr, cg, cb, ca, cf);
obj.join("type_coloredrect");
return obj;
}
public function SimpleColoredRect(objname, nx, ny, nw, nh, cr, cg, cb, ca) {
temp.obj = this.Rect(objname, nx, ny, nw, nh);
obj.red = cr;
obj.green = cg;
obj.blue = cb;
obj.alpha = ca;
obj.join("type_simplecoloredrect");
return obj;
}
public function Color(objname, cr, cg, cb, ca, cf) {
temp.obj = new TStaticVar(""@objname);
obj.red = cr;
obj.green = cg;
obj.blue = cb;
obj.alpha = ca;
obj.float = cf;
obj.join("type_color");
return obj;
}
// Class Script: type_color
public function toint() {
if (this.float) {
this.check();
this.red = int(this.red * 255);
this.green = int(this.green * 255);
this.blue = int(this.blue * 255);
this.alpha = int(this.alpha * 255);
this.float = false;
}
}
public function tofloat() {
if (!this.float) {
this.check();
this.red = this.red / 255;
this.green = this.green / 255;
this.blue = this.blue / 255;
this.alpha = this.alpha / 255;
}
}
public function check() {
if (this.float) {
for (temp.i: {"red", "green", "blue", "alpha"}) {
if (this.(@ i) > 1)
this.(@ i) = 1;
else if (this.(@ i) < 0)
this.(@ i) = 0;
}
}
else {
for (temp.i: {"red", "green", "blue", "alpha"}) {
if (this.(@ i) > 255)
this.(@ i) = 255;
else if (this.(@ i) < 0)
this.(@ i) = 0;
}
}
}
I don't use inheritance myself because the time I did I found I was overcomplicating the script (a large one) and stopped doing it. Instead I now just have a single class that does everything, even stuff you might not need it for, rather like TShowImg.
So how would you implement inheritance in Graal?
Quote:
Originally Posted by Programmer
I'd also like to point out that I said classes within Weapon scripts, not class scripts.
|
Classes should be global in all cases. We certainly don't need classes specific to a script.
Quote:
Originally Posted by Programmer
Creating a class in a Weapon script is much different than in a class script.
|
Obviously. What you should have is a script to control all the classes on your server and not be specific to any object's script.
Edit: By the way PFA (?), if Graal didn't have a garbage collector you would cause memory leak with that
