Console Iheritence and namespaces
by Devboy · in Torque Game Engine · 03/02/2004 (4:58 am) · 1 replies
Hi,
I'm trying to create a generic Action datablock class in such a way that every 'named' datablock I create from it will have a different onAction() method.
I have class Action : public simDataBlock and did the following in the script...
Then I call from somwhere within the C++ code (this is approximate, can't remember what exactly I did here but it finds the relevant datablock for sure!!) :
The function onAction() does not get calle. From what I saw the engine treats the retrived SimObj as belonging to namespace 'Action' (if this has any bearing). The reason I believed this would work is the following bit of codes cut-pasted from starter.fps.
note that I couldn't find a declaration for an 'Ammo' namespace anywhere else in the code.
Can anyone explain why I don't get the same results as starter.fps. Or suggest a better way to do what I'm trying to?
Thanks
I'm trying to create a generic Action datablock class in such a way that every 'named' datablock I create from it will have a different onAction() method.
I have class Action : public simDataBlock and did the following in the script...
datablock Action(MoveAct)
{
//blah blah
className = someNameSpace; //I got this from starter.fps
//blah blah
}
function someNameSpace::onAction(%this, %stuff)
{
//does something
}Then I call from somwhere within the C++ code (this is approximate, can't remember what exactly I did here but it finds the relevant datablock for sure!!) :
pSimObj = Sim::findObject("MoveAct"); //hardcoded for testing
Con::executef(pSimObj, 2, "onAction", param);The function onAction() does not get calle. From what I saw the engine treats the retrived SimObj as belonging to namespace 'Action' (if this has any bearing). The reason I believed this would work is the following bit of codes cut-pasted from starter.fps.
// Add the Ammo namespace as a parent. The ammo namespace provides
// common ammo related functions and hooks into the inventory system.
className = "Ammo";
//Then there's
function Ammo::onPickup(%this, %obj, %shape, %amount)
{
// The parent Item method performs the actual pickup.
if (Parent::onPickup(%this, %obj, %shape, %amount)) {
serverPlay3D(AmmoPickupSound,%obj.getTransform());
}
} note that I couldn't find a declaration for an 'Ammo' namespace anywhere else in the code.
Can anyone explain why I don't get the same results as starter.fps. Or suggest a better way to do what I'm trying to?
Thanks
About the author
Torque Owner Devboy
www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=2212