Game Development Community

Giving an item dynamic on creation

by Christian · in Torque Game Engine · 05/05/2007 (8:46 am) · 2 replies

Is there a way to give an item you create a set of dynamic fields? So whenever I add one of these:

datablock StaticShapeData(ChocolateMarker)
{
   category = "Chocolate";
   shapeFile = "~/data/shapes/bars/chocolate.dts";
};

in game. I need it to have

ChocolateMarker.meltSpeed = 0.35;
ChocolateMarker.aroma = 0.035;
ChocolateMarker.taste = 1;

#1
05/05/2007 (9:31 am)
datablock StaticShapeData(ChocolateMarker)
{
   category = "Chocolate";
   shapeFile = "~/data/shapes/bars/chocolate.dts";
};

function ChocolateMarker::onAdd(%this,%obj)
{
   %obj.meltSpeed = 0.35;
   %obj.aroma = 0.035;
   %obj.taste = 1;
}
Place a ChocolateMarker in your world with the world editor, select it and hit F3 to view its properties. You will see your values listed.

Naturally, the above tags can be returned in script.
#2
05/09/2007 (12:17 pm)
Thanks Tim. As of now it gives each marker a set of dynamic fields that are preset in script.

If I change a dynamic field on each individual marker that I place and save they revert to the ::onAdd default values.

Is there a way to fix that?