Game Development Community

Unknow command getDataBlock

by Mdk_4_ever Na · in Technical Issues · 04/10/2007 (3:09 pm) · 13 replies

I get this error message "unknow command getDataBlock" when I try to execute the following code:

function serverCmdOperate1(%client){
error("start to operate");
%player = %client.player;
%eye = %player.getEyeVector();
%vec = VectorScale(%eye, $DOORS::PLAYER_REACH);
%start = %player.getEyeTransform();
%end = VectorAdd(%start, %vec);
%found = ContainerRayCast(%start, %end, $TypeMasks::StaticObjectType, %player);

if(%found)
%found.getDataBlock().Operate(%found); //<<========= error here

}

thanks

#1
04/10/2007 (3:55 pm)
ContainerRayCast doesn't return an object, it returns a list of stuff. (Can't remember exactly what at the moment, you'd have to look it up yourself but I believe the first value in the list should be the id of the object hit then after that you get some information like the position and normal of the hit).
#2
04/11/2007 (4:22 am)
Alot of mistakes in the book "3d game programming all in one"

but why I get this err message , is there any thing wrong with the syntax of getDataBlock() ?
the error should tell me invalid object "%found" or something like that !!!!!!!!!

thanks
#3
04/11/2007 (5:17 am)
As Magnus said, ContainerRayCast returns a list of values. The first value being the ID of the object, so you need to get the first value before you do the getDataBlock.

if (%found)
  {
      %objID = firstWord(%found);
      %objID.getDataBlock().Operate( %objID );
      // Note:  I am assuming the function Operate needs the ID of the object and not the list of values.
  }
#4
04/11/2007 (8:18 am)
Many thanks
#5
04/11/2007 (1:34 pm)
But I still got the same error !!!
#6
04/11/2007 (1:50 pm)
Add an echo to the function to show the contents of %found. Re run the app until you get the error

Then post the last few lines of the log including the error.

Also repost the changed function so I can look at both the log and the function please.
#7
04/11/2007 (2:13 pm)
I assume you have the code? A simple investigation into the return values of ContainerRayCast would show that some sort of value is always returned. You have to check the value to see if you got any hits. So your orginal code would always get executed due to %found always having a value. But if the value is zero, then getDataBlock() will fail.

if(%found)
      %found.getDataBlock().Operate(%found);



Try this code, note the differences at the bottom of the function.

function serverCmdOperate1(%client){
   error("start to operate");
   %player = %client.player;
   %eye = %player.getEyeVector();
   %vec = VectorScale(%eye, $DOORS::PLAYER_REACH);
   %start = %player.getEyeTransform();
   %end = VectorAdd(%start, %vec);
   %found = ContainerRayCast(%start, %end, $TypeMasks::StaticObjectType, %player);
[b]  
   %objID = firstWord( %found );
   if (%objID != 0)
       %objID.getDataBlock().Operate(%objID);
   else
       echo("No objects in reach");
[/b]   
}

I am still unsure what the Operate function is expecting as a parameter, so you may want to double check that.
#8
04/11/2007 (4:24 pm)
I checked %found and I get data correctly

function serverCmdOperate1(%client){
%player = %client.player;
%eye = %player.getEyeVector();
%vec = VectorScale(%eye, $DOORS::PLAYER_REACH);
%start = %player.getEyeTransform();
%end = VectorAdd(%start, %vec);
%found = ContainerRayCast(%start, %end, $TypeMasks::StaticObjectType, %player);
echo(%found);

%objID = firstWord(%found);
if (%objID != 0)
%objID.getDataBlock().Operate(%objID); <<------------ unknown command here
else
echo("No objects in reach");

//if(%found) {
//%objID.getDataBlock().Operate(%objID);


//}

}

function ADoor::Operate(%theDataBlock, %whichDoor){

if (%whichDoor.doorOpenFlag == false){

%theDataBlock.startopenswing(%whichDoor);
}

}

=========================================
any idea ?
THANKS
#9
04/11/2007 (5:42 pm)
OK, I see what your running into now.

The function getDataBlock hangs off the GameBase class. Not all objects of StaticObjectType are based on the GameBase class. For instance, an Interior is of a StaticObjectType but it is based off the SceneObject class not the GameBase.

I expect your returning an object that is not based on the GameBase class and so you are getting the error.

There are a number of ways you can do this, but in the end you need to make sure its a GameBase classed object before calling getDataBlock().

Btw, any time you get a script error and your asking on the forum for help, it helps if you can post some of the log around the error as well. I relized what was happening when I recreated what you where doing and looked at my own log. Could of saved time if you had posted yours.
#10
04/12/2007 (9:29 am)
BIG THANKS

I will continue reading "3d programming all in one" book hoping that I can figure out what the author want to do !!!

If you need any help from me contact me at this email mdk_4_everYahoocom

THANKS and sorry for the trouble
#11
04/14/2007 (8:22 am)
I know now why I get this error because I was selecting the door from the static shapes , now the getDataBlock did not give me an error but after I press "o" to open the door the TGE crashes and a windows message appear with close button !!

I dont know even how to get the line that cause the error, and advice plz?

Thanks
#12
04/14/2007 (8:38 am)
A couple of things you can do to try and figure it out.

If the function startopenswing is C++ code, then put a break point in where that code is being executed and then step though it.

Otherwise, you can put messages in your script at select points, that way you will know you at least got up to that message before it died.

Both these ways will help you narrow down what you don't know.
#13
04/14/2007 (2:02 pm)
No this is a torque script , how I can display messages I know only echo , error and they are useless because all the engine crashes

thanks