FANDOM


The Parent keyword is used with the namespace operator (::) to reference the previous definition of a function that has been overridden either through inheritance or packaging. The Parent keyword can only be used within specific contexts:

  • From within a consoleMethod, or
  • from within a packaged function.
//Calling an inherited parent
datablock ItemData( GoldCoin )
{
...
};

function ItemData::onAdd( %db, %obj )
{
echo( "ItemData::onAdd()" );
}

function GoldCoin::onAdd( %db, %obj )
{
Parent::onAdd( %db, %obj );

echo( "GoldCoin::onAdd()" );
}

//Calling a parent
function testFunction()
{
echo( "testFunction() - unpackaged." );
}

MyPackage0
{
function testFunction()
{
Parent::testFunction();
echo( "testFunction() - MyPackage0." );
}
};
...
testFunction();
//prints => testFunction() - unpackaged.

ActivatePackage( MyPackage0 );
testFunction();
// prints => testFunction() - unpackaged.
// prints => testFunction() - MyPackage0.

See Also Edit

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.