Problem with script object properties
by Robert Rice · in Torque Game Engine Advanced · 06/19/2009 (5:13 pm) · 3 replies
I'm trying to implement the door resource from Ken Finney's book Advanced 3d Game Programming All In One in TGEA 1.8.1. I was having problems so I chopped away at the code to get just what I needed to try to solve my problem. I have a datablock defined as:
datablock StaticShapeData(ADoor){
category = "Doors";
shapeFile = "~/.../door.dts";
};
I then define the onAdd function as:
function ADoor::onAdd(%theDatablock, %whichDoor){
%whichDoor.robert = "r";
%whichDoor.robert = "b";
}
I threw in some calls to echo to ensure the value of %whichDoor.robert is being set correctly each time. In the console, I see an "r" on the first call and a "b" on the second call as expected. All is well.
I implement a serverCmd function that sends out a container ray cast to find the door object, which it does; I place that result in a variable called %found. I make another call to echo to look at the %found.robert value again and it is blank. This is where I get confused because I added a call to dump right after that and the value shows up as "b", as expected under the "tagged variables" list from the dump. This is causing me much frustration because ADoor has about 4 other variables that I need that are doing the same thing.
What am I doing wrong here or missing?
Thanks!
datablock StaticShapeData(ADoor){
category = "Doors";
shapeFile = "~/.../door.dts";
};
I then define the onAdd function as:
function ADoor::onAdd(%theDatablock, %whichDoor){
%whichDoor.robert = "r";
%whichDoor.robert = "b";
}
I threw in some calls to echo to ensure the value of %whichDoor.robert is being set correctly each time. In the console, I see an "r" on the first call and a "b" on the second call as expected. All is well.
I implement a serverCmd function that sends out a container ray cast to find the door object, which it does; I place that result in a variable called %found. I make another call to echo to look at the %found.robert value again and it is blank. This is where I get confused because I added a call to dump right after that and the value shows up as "b", as expected under the "tagged variables" list from the dump. This is causing me much frustration because ADoor has about 4 other variables that I need that are doing the same thing.
What am I doing wrong here or missing?
Thanks!
#2
As Sean said, containerRayCast returns a vector of values. Here's the documentation:
So, before doing a %found.robert, do this:
06/21/2009 (2:40 pm)
As Sean said, containerRayCast returns a vector of values. Here's the documentation:
ConsoleFunction( containerRayCast, const char*, 4, 5, "( Point3F start, Point3F end, bitset mask, SceneObject exempt=NULL )"
"Cast a ray from start to end, checking for collision against items matching mask.\n\n"
"If exempt is specified, then it is temporarily excluded from collision checks (For "
"instance, you might want to exclude the player if said player was firing a weapon.)\n"
"@returns A string containing either null, if nothing was struck, or these fields:\n"
" - The ID of the object that was struck.\n"
" - The x, y, z position that it was struck.\n"
" - The x, y, z of the normal of the face that was struck.")So, before doing a %found.robert, do this:
%found = getWord( %found, 0 );
#3
06/21/2009 (7:43 pm)
Thanks, guys! That did the trick!
Torque 3D Owner Sean H.