Blank echo
by Andrew "Anger" · in Torque Game Engine · 12/25/2005 (5:50 am) · 6 replies
The problem is as follows :
I have added a new field named "itemName" to the Item class... Then an item gets created in fps.mis
new Item()
{
position = "363.45 73.9016 183.526";
rotation = "1 0 0 0";
scale = "1 1 1";
dataBlock = "Crossbow";
collidable = "0";
static = "1";
rotate = "1";
itemName = "Mega Blaster";
};
Now, when the client receives the string, I should be able to echo it from the console... But it doesn't work!
Calling echo(SimObj_ID.itemName) results in a blank output... I've tried to detag it, but it didn't help either. What's curious is that calling obj.dump() on this item shows that the field itemName HAS the value "Mega Blaster", and Con::printf() from C++ also produces output "Mega Blaster"... Why doesn't it get echoed, then?
Thanks in advance!
I have added a new field named "itemName" to the Item class... Then an item gets created in fps.mis
new Item()
{
position = "363.45 73.9016 183.526";
rotation = "1 0 0 0";
scale = "1 1 1";
dataBlock = "Crossbow";
collidable = "0";
static = "1";
rotate = "1";
itemName = "Mega Blaster";
};
Now, when the client receives the string, I should be able to echo it from the console... But it doesn't work!
Calling echo(SimObj_ID.itemName) results in a blank output... I've tried to detag it, but it didn't help either. What's curious is that calling obj.dump() on this item shows that the field itemName HAS the value "Mega Blaster", and Con::printf() from C++ also produces output "Mega Blaster"... Why doesn't it get echoed, then?
Thanks in advance!
About the author
#2
U32 Item::packUpdate(NetConnection *connection, U32 mask, BitStream *stream)
{
if(stream->writeFlag(mask & InitialUpdateMask))
{
...
stream->writeString(mItemName);
}
...
}
And it also gets unpacked in unpackUpdate() like this
mItemName = stream->readSTString(true);
Besides, I called Con::printf(mItemName); from Item::renderImage() which gets called on client only... (or am I wrong?)... And it printed "Mega Blaster" every frame, when the item got rendered. From this I assume, that the string should be on the client... But still it doesn't get echoed...
12/27/2005 (4:01 am)
That's exactly the case - the field is written in C++, and it gets packed in packUpdate()U32 Item::packUpdate(NetConnection *connection, U32 mask, BitStream *stream)
{
if(stream->writeFlag(mask & InitialUpdateMask))
{
...
stream->writeString(mItemName);
}
...
}
And it also gets unpacked in unpackUpdate() like this
mItemName = stream->readSTString(true);
Besides, I called Con::printf(mItemName); from Item::renderImage() which gets called on client only... (or am I wrong?)... And it printed "Mega Blaster" every frame, when the item got rendered. From this I assume, that the string should be on the client... But still it doesn't get echoed...
#3
12/27/2005 (4:05 am)
You're probably trying to use the server object ID rather than the client's object ID.
#4
12/27/2005 (5:01 am)
Yep... seems like this is the case! Thanks :)
#5
12/27/2005 (12:47 pm)
Well, it seems that I started to celebrate too soon... I checked, and it seems like it IS client's object ID, rather than server's... And it still doesn't get echoed! Now that I've checked, none of the Item's fields get echoed, when I use object's ID... However if I use object's name instead of ID, everything works just fine... This is starting to give me a headache... :(
#6
12/31/2005 (2:52 pm)
The object name isn't sent over to the client.
Associate Kyle Carter
If you want it to be on the client you have to put it there. :)