Game Development Community

Getting RTSUnitTypeName from the engine

by Liu Yi · in RTS Starter Kit · 05/22/2006 (2:43 am) · 2 replies

Hi, i'm kinda new to torque and am working on a city building game based on the rts starter kit

I need to get the RTSUnitTypeName from the datablock (shown below) in the engine but i don't really know how to access it...

datablock RTSUnitData(r_tileBlock : UnitBaseBlock)
{
   shapeFile = "~/data/shapes/tiles/r_tile.dts";
   RTSUnitTypeName = "ResidentialTile";   
   boundingBox = "32.0 32.0 6.0";
};


using the following code,

RTSUnit* unit = dynamic_cast<RTSUnit*>(ri.object);

Con::printf("ClassName = %s",unit->getClassName() ); //gives me RTSBuilding 
Con::printf("db ClassName = %s",unit->getDataBlock()->className );  //gives me RTSUnitData

is there any way to retrieve the string "ResidentialTile" from the engine?


regards
Liuyi

#1
05/22/2006 (7:35 am)
You cant access script variables from the engine, I dont think. Declare it in the datablock class and access it from there or do it on the actual object class. I dont know very much about C++ so dont totally take my word for it :p
#2
05/23/2006 (2:15 am)
Okies never mind.

I just found out tat i just needed to add the field in the engine
thanks for replying anyway =)