Thread: Gs3
View Single Post
  #94  
Old 06-18-2013, 01:58 AM
Twinny Twinny is offline
My empire of dirt
Twinny's Avatar
Join Date: Mar 2006
Location: Australia
Posts: 2,422
Twinny is just really niceTwinny is just really nice
Send a message via AIM to Twinny
Encountered some issues with inheritance,

PHP Code:
//#GS3

class BaseClass {
  var 
baseclassvar number 3;
  
  function 
overwriteMe() : string {
    return 
"You shouldn't see me without accessing baseclass";
  }
}

class 
InheritanceTest extends BaseClass {
  function 
overwriteMe() : string {
    return 
"You should see me!";
  }
}

function 
onCreated() : void {
  
//var BaseClassTest : BaseClass = new BaseClass();
  //echo(BaseClassTest.baseclassvar);
  
  
var TestObj InheritanceTest = new InheritanceTest();
  echo(
TestObj.baseclassvar);
  echo(
TestObj.overwriteMe());

would spit out,

PHP Code:
Weapon/GUI-script Twinny/GS3-Inheritance added/updated by Twinny
Script
Couldn't create object: type BaseClass is not existing in function onCreated in script of Twinny/GS3-Inheritance
Script: Function TestObj.overwriteMe not found in function onCreated in script of Twinny/GS3-Inheritance

Next, uncommenting the lines resulted in,

PHP Code:
Weapon/GUI-script Twinny/GS3-Inheritance added/updated by Twinny
Script
Couldn't create object: type BaseClass is not existing in function onCreated in script of Twinny/GS3-Inheritance
Script: Function TestObj.overwriteMe not found in function onCreated in script of Twinny/GS3-Inheritance
0
bytecode:1305: TypeError: Cannot read property '
name' of null
      typeName = stub.name.extends.name;
                                  ^
Will keep running the old NPC script until server restart. 

I was going to try and do a var BaseTestObj : BaseClass = TestObj; but figured it wouldn't get me too far
Reply With Quote