Datablock inheritance not working
by Vern Jensen · in Torque Game Builder · 07/04/2006 (5:32 pm) · 5 replies
According to this documentation:
http://www.garagegames.com/docs/tge/general/ch05s04.html
you should be able to make one datablock "inherit" values from the other. So I've done this for some animation datablocks:
The idea is that gem3Selected and gem4Selected should inherit the values from baseSelected. Yet, the gem3Selected and gem4Selected animations behave exactly as they would if they had not inherited any values. I have to manually add the values to EACH datablock to get it to work right, resulting in LOTS of redundant code if you have a lot of these things:
Is this a bug? Or has the way to "extend" a datablock changed since the documentation referenced above was written?
http://www.garagegames.com/docs/tge/general/ch05s04.html
you should be able to make one datablock "inherit" values from the other. So I've done this for some animation datablocks:
datablock t2dAnimationDatablock( baseSelected )
{
animationCycle = 1;
animationTime = 1;
canSaveDynamicFields = 1;
randomStart = 0;
startFrame = 0;
animationFrames = "15 16 17 18 19 20 21 22 23 24 25 26 27 28 29";
};
datablock t2dAnimationDatablock(gem3Selected : baseSelected)
{
imageMap = gem3ImageMap;
};
datablock t2dAnimationDatablock(gem4Selected : baseSelected)
{
imageMap = gem4ImageMap;
};The idea is that gem3Selected and gem4Selected should inherit the values from baseSelected. Yet, the gem3Selected and gem4Selected animations behave exactly as they would if they had not inherited any values. I have to manually add the values to EACH datablock to get it to work right, resulting in LOTS of redundant code if you have a lot of these things:
datablock t2dAnimationDatablock( baseSelected )
{
animationCycle = 1;
animationTime = 1;
canSaveDynamicFields = 1;
randomStart = 0;
startFrame = 0;
animationFrames = "15 16 17 18 19 20 21 22 23 24 25 26 27 28 29";
};
datablock t2dAnimationDatablock(gem3Selected : baseSelected)
{
imageMap = gem3ImageMap;
animationCycle = 1;
animationTime = 1;
canSaveDynamicFields = 1;
randomStart = 0;
startFrame = 0;
animationFrames = "15 16 17 18 19 20 21 22 23 24 25 26 27 28 29";
};
datablock t2dAnimationDatablock(gem4Selected : baseSelected)
{
imageMap = gem4ImageMap;
animationCycle = 1;
animationTime = 1;
canSaveDynamicFields = 1;
randomStart = 0;
startFrame = 0;
animationFrames = "15 16 17 18 19 20 21 22 23 24 25 26 27 28 29";
};Is this a bug? Or has the way to "extend" a datablock changed since the documentation referenced above was written?
#2
So for me, whether it's "new" or "datablock", I still don't get my datablocks to inherit from the previous datablock the way they're supposed to. Can you post some of your working code? I'm just curious what it looks like.
07/05/2006 (12:21 am)
I assume you mean using the keyword "new" *instead* of "datablock". I had already tried that -- didn't help. I also just now tried "new datablock" just in case, but that just generates a syntax error.So for me, whether it's "new" or "datablock", I still don't get my datablocks to inherit from the previous datablock the way they're supposed to. Can you post some of your working code? I'm just curious what it looks like.
#3
07/05/2006 (12:32 am)
I'm pretty sure I got this working with t2dSceneObjectDatablocks - but I'll have to verify with my code at home.
#4
07/05/2006 (12:50 am)
Here's the sample from my completely working code:new t2dAnimationDatablock(selectBase)
{
canSaveDynamicFields = true;
imageMap = "selectionsImageMap";
animationTime = "0.5";
animationCycle = true;
randomStart = false;
startFrame = "0";
};
new t2dAnimationDatablock(selectWhite : selectBase)
{
animationFrames = "0 0 0 1 2 2 2 1";
};
new t2dAnimationDatablock(selectOrange : selectBase)
{
animationFrames = "3 3 3 4 5 5 5 4";
};
new t2dAnimationDatablock(selectBlue : selectBase)
{
animationFrames = "6 6 6 7 8 8 8 7";
};
new t2dAnimationDatablock(selectYellow : selectBase)
{
animationFrames = "9 9 9 10 11 11 11 10";
};
new t2dAnimationDatablock(selectGreen : selectBase)
{
animationFrames = "12 12 12 13 14 14 14 13";
};
#5
Turns out I had an error in my console log all along that I never saw. I'm still getting used to that console log. Stuff can get buried way up in the log, so you don't see it unless you scroll up.
Anyway, thanks all for the help
07/05/2006 (1:20 am)
Ahhhh! I found my problem. My code didn't set imageMap equal to anything in the parent datablock that the others inherited from. This is because the ones that inherited set it themselves -- each one to something different. This was the unique part that changed per datablock. But it turns out Torque barfs if you don't set the imageMap in a t2dAnimationDatablock -- and fails to create it!Turns out I had an error in my console log all along that I never saw. I'm still getting used to that console log. Stuff can get buried way up in the log, so you don't see it unless you scroll up.
Anyway, thanks all for the help
Torque Owner Ben R Vesco