Thread: Custom Classes!
View Single Post
  #10  
Old 12-09-2007, 05:46 PM
Novo Novo is offline
[TServerDeveloper]
Join Date: Jun 2006
Posts: 448
Novo will become famous soon enough
Quote:
Originally Posted by Inverness View Post
onCreated does not work like this
PHP Code:
public function newInstanceparamobjectName )
{
  if ( 
objectName != "" )
    if ( (@ 
objectName ).type() == )
      (@ 
objectName ).destroy();

  
// Initialize Class
  
if ( objectName == "" )
    
temp.newInstance = new TStaticVar();
  else 
temp.newInstance = new TStaticVar( @objectName );

  
temp.newInstance.class = this;
  
temp.newInstance.join( ("class_"this.name).lower() );

  
// Initialize Object
  
if ( this.name in temp.newInstance.getfunctions() )
    
temp.newInstance.(@ this.name )( param );

  return 
temp.newInstance;

I made a turnaround for that onCreated problem. Basically, the newInstance() would call the constructor for the class ( thus, TNode )

PHP Code:
public function TNode() { foo; } 
Makes sure that the initialize variables are initialized immediately.

Such as:
PHP Code:
function onCreated()
{
 array = 
TMap.newInstance( {{"Test3""333"}} );
 array.
put("Test"123);
 array.
put("Test2"123);
 array.
put("Test"321);
 echo( array.
toString() ); // output: "Test3,333","Test,321","Test2,123"

EDIT: I'm thinking of having an inheritance system working out... So one could probably do an object.class.instanceof( otherclass )... Something along the lines of:
PHP Code:
public function instanceOf( class )
{
  if ( 
this == class )
    return 
true;
  
// for ( superClass: superClasses )
  //   if ( superClass.instanceOf( class ) )
  //      return true;
  
return false;

Reply With Quote