unable to find datablock?
by Neil Marshall · in Torque Game Engine · 09/07/2002 (7:13 pm) · 3 replies
I've implemented the ability to throw my weapon when it is fired using this Throwing code snippit.
I can pickup the item, throw it, but when I pick it up again, I get this in the console:
Unable to find object: '1418' attempting to call function 'getDataBlock'
It picks it up fine, it's just writing that line in the console which I want to stop. I'm sure I can just put a return on the function where it's having the problem, but I would like to know why there isn't a datablock associated with it.
Where it runs into the problem calling getDataBlock():
This is the code that creates the object (%data is the name of my datablock):
Now, as far as I can tell, I'm creating a datablock, because I can see the object that I'm throwing. So why am I getting this error?
I'm stumped as to how to go about fixing or debugging it.
I can pickup the item, throw it, but when I pick it up again, I get this in the console:
Unable to find object: '1418' attempting to call function 'getDataBlock'
It picks it up fine, it's just writing that line in the console which I want to stop. I'm sure I can just put a return on the function where it's having the problem, but I would like to know why there isn't a datablock associated with it.
Where it runs into the problem calling getDataBlock():
function Armor::onCollision(%this,%obj,%col,%vec,%speed)
{
if (%obj.getState() $= "Dead")
return;
// Try and pickup all items
if (%col.getClassName() $= "Item")
%obj.pickup(%col);
// Mount vehicles
%this = %col.getDataBlock();This is the code that creates the object (%data is the name of my datablock):
function ShapeBase::throwItem(%this, %data)
{
// Construct item to throw from the given datablock
// (with a random rotation around the z axis)
%item = new Item() {
dataBlock = %data;
rotation = "0 0 1 " @ (getRandom() * 360);
};
// Make sure the object will be deleted when the
// mission ends.
MissionCleanup.add(%item);
// Call the workhorse throw method...
%this.throwObject(%item);
}Now, as far as I can tell, I'm creating a datablock, because I can see the object that I'm throwing. So why am I getting this error?
I'm stumped as to how to go about fixing or debugging it.
Torque Owner Sam Guffey
function Armor::onCollision(%this,%obj,%col,%vec,%speed) { if (%obj.getState() $= "Dead") return; // Try and pickup all items if (%col.getClassName() $= "Item") %obj.pickup(%col); // Mount vehicles if(%col.getClassName() $= "WheeledVehicle" || %col.getClassName() $= "FlyingVehicle") { %this = %col.getDataBlock();Then close it off so no other collision object runs this getDatablock call.*EDIT* Fixed