Understanding datablocks and inheritance
by daffodilistic · in Torque Game Builder · 11/09/2010 (4:34 am) · 1 replies
Hi all,
according to http://tdn.garagegames.com/wiki/TorqueScript/Namespaces, I should be able to call CrossbowAmmo.onPickup, and it should call Ammo.onPickup. Simplifying the code from the article:
I get the error:
Is the article outdated, or am I doing things wrongly here?
according to http://tdn.garagegames.com/wiki/TorqueScript/Namespaces, I should be able to call CrossbowAmmo.onPickup, and it should call Ammo.onPickup. Simplifying the code from the article:
datablock SimDataBlock(CrossbowAmmo)
{
className = "Ammo";
dummyVal = 1;
};
function Ammo::onPickup(%AmmoDB)
{
echo ("Calling Ammo::onPickup () ==> on ammo DB" SPC %AmmoDB);
}
%test = new SimObject("TestClass")
{
datablock = "CrossbowAmmo";
};
%test.onPickup();I get the error:
Unknown command onPickup. Object TestClass(1358) TestClass -> SimObject
Is the article outdated, or am I doing things wrongly here?
Torque 3D Owner Eric Armstrong
Bloody Tongue Games
Something like this should work I think:
%test = new SimObject("TestClass") { datablock = "CrossbowAmmo"; }; %test.datablock.onPickup();Assigning a datablock to an object doesn't cause the object to inherit the information in the datablock, it just assigns the datablock to the object.
Hope that makes sense.