.setClass(CLASS DATABLOCK);") { object->setClass((playerClassData)argv[2]); } Where "> Datablock From String | Torque Game Engine | Forums | Community | GarageGames.com

Game Development Community

Datablock From String

by Matt "Mr. Pig" Razza · in Torque Game Engine · 05/07/2007 (2:45 pm) · 2 replies

Is it possible to find the datablock in the engine from the datablocks name (in char format).

For example:
ConsoleMethod(Player, setClass, void, 3, 3, "<player>.setClass(CLASS DATABLOCK);")
{
	object->setClass((playerClassData)argv[2]);
}

Where playerClassData is a datablock class and argv[2] contains the string for the name of the given datablock (this is a typecast example).

Thanks.

#1
05/09/2007 (4:36 pm)
^^Bump^^
#2
05/09/2007 (5:18 pm)
Sim::findObject("datablock name");

That's the command you want in C++. Just pass the string containing the name into the method.