View Single Post
  #9  
Old 03-13-2008, 01:44 AM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
Quote:
Originally Posted by Programmer View Post
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(objnamenxnynwnhcrcgcbcacf) {
  
temp.obj this.Rect(objnamenxnynwnh);
  
obj.color this.Color(nullcrcgcbcacf);
  
obj.join("type_coloredrect");
  return 
obj;
}
public function 
SimpleColoredRect(objnamenxnynwnhcrcgcbca) {
  
temp.obj this.Rect(objnamenxnynwnh);
  
obj.red cr;
  
obj.green cg;
  
obj.blue cb;
  
obj.alpha ca;
  
obj.join("type_simplecoloredrect");
  return 
obj;
}
public function 
Color(objnamecrcgcbcacf) {
  
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 View Post
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 View Post
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
__________________

Last edited by Inverness; 03-13-2008 at 06:11 AM..
Reply With Quote