Blockland Wiki
Advertisement

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[]

Advertisement