Add dynamic field from script
by Owen Ortmayer · in Torque Game Engine · 05/04/2004 (9:30 am) · 3 replies
Is there a way to add a dynamic field on the fly from a script. I want to have a set of objects that are the same base class, but differentiate thier behavior thorugh scripts. I want the ability to add dynamic fields as needed that will show up in the world editor inspector. You can override the datablock::create() function and add in dynamic fields:
function StaticShapeData::create(%data)
{
// The mission editor invokes this method when it wants to create
// an object of the given datablock type.
%obj = new StaticShape() {
dataBlock = %data;
dynamicField = "thisIsADynamicField";
};
return %obj;
}but that only applies to the base object(StaticShape here).About the author
Torque Owner Owen Ortmayer
function StaticShapeData::create(%data) { //see if we want to do something special switch$( %data.getName() ) { case "TypeThatNeedsDynamicField": %obj = new StaticShape() { dataBlock = %data; dynamicFiled = "thisIsADynamicField"; }; return %obj; } //do default behavior %obj = new StaticShape() { dataBlock = %data; }; return %obj; }