Has custom datablock issue been addressed in TGB 1.6
by Stanley D Chatman · in Torque Game Builder · 01/29/2008 (6:56 pm) · 11 replies
In the TGB 1.5 I had to put my custom config datablocks in the behavior directory in order to get them visible in the GUI editor. Is this still the case in TGB 1.6 if not where do they go now?
#2
01/31/2008 (1:32 pm)
Matt, as far as I am aware (as of about 30seconds ago), datablocks in the datablocks.cs file are not loaded into TGB 1.6 or 1.7. I can manually add them to the managed set, and that loads them into the editor, otherwise they do not load.
#3
01/31/2008 (2:01 pm)
Hmm, well I just tested it in 1.6 and 1.7 and works fine for me. I tested it using the datablock from the Fish Demo Tutorial.
#4
01/31/2008 (2:07 pm)
My datablocks.cs looks like this//---------------------------------------------------------------------------------------------
// Torque Game Builder
// Copyright (C) GarageGames.com, Inc.
//---------------------------------------------------------------------------------------------
//
// This is the file you should define your custom datablocks that are to be used
// in the editor.
//
datablock t2dSceneObjectDatablock(FishDatablock) {
Class = "FishClass";
Layer = "16";
WorldLimitMode = "NULL";
WorldLimitMin = "-66.2102 -45";
WorldLimitMax = "66.1003 45";
WorldLimitCallback = "1";
minSpeed = "5";
maxSpeed = "25";
};
datablock t2dSceneObjectDatablock(FishDatablock2) {
Class = "FishClass";
Layer = "16";
position = "50 50";
};
datablock t2dSceneObjectDatablock(FishDatablock3) {
Class = "FishClass";
Layer = "16";
GraphGroup = "5";
};
#5
01/31/2008 (4:08 pm)
It works for me using the prescribed method Matt discussed. I have TGB 1.6 and just installed TGB 1.7.
#6
It works when I add an additional line: $managedDatablockSet.add(MyTemplate);
Okay, I can now see them in the editor, however, I cannot use them in my behaviors, only for the scene object's config script.
01/31/2008 (6:29 pm)
Mmmmm, not working for me. The file is loaded when the game is run and when the editor is loaded, however the datablocks in side are not added to managed set.It works when I add an additional line: $managedDatablockSet.add(MyTemplate);
Okay, I can now see them in the editor, however, I cannot use them in my behaviors, only for the scene object's config script.
#7
01/31/2008 (6:51 pm)
That was the problem for me too going back to TGB 1.5. I could never use them in my behaviors unless I put them in the behaviors directory at which point they wre automatically loaded. I'm going to test and see how it works for me.
#8
01/31/2008 (10:56 pm)
I use Vista and my previous tests were Vista, hmm.
#9
02/01/2008 (11:40 am)
Matt, should they be working in the behaviors? My type field is set to "object" and the datafield is set to "t2dSceneObjectDatablock".
#10
- managed set
- the existing scenegraph you are editing
If you have a pro license you can make this work by opening the script file: "tools/behaviorEditor/Scripts/fieldTypes.cs" go to line 98 and make your "function BehaviorFieldStack::createObjectGui(%this, %behavior, %fieldIndex)" look like this:
02/01/2008 (12:06 pm)
You are correct, they won't load into behaviors. As you did previously, adding them into the managed set, they will since currently this is what gets checked for any behavior lists of the object type:- managed set
- the existing scenegraph you are editing
If you have a pro license you can make this work by opening the script file: "tools/behaviorEditor/Scripts/fieldTypes.cs" go to line 98 and make your "function BehaviorFieldStack::createObjectGui(%this, %behavior, %fieldIndex)" look like this:
function BehaviorFieldStack::createObjectGui(%this, %behavior, %fieldIndex)
{
%fieldInfo = %behavior.template.getBehaviorField(%fieldIndex);
%name = getField(%fieldInfo, 0);
%description = %behavior.template.getBehaviorFieldDescription(%fieldIndex);
%objectType = %behavior.template.getBehaviorFieldUserData(%fieldIndex);
// Everything we could possibly want should be contained in either the
// scenegraph or the managed datablock set.
%scenegraph = ToolManager.getLastWindow().getSceneGraph();
%count = %scenegraph.getSceneObjectCount();
%list = "None";
for( %i = 0; %i < %count; %i++ )
{
%sceneObject = %scenegraph.getSceneObject( %i );
if( !%sceneObject.isMemberOfClass( %objectType ) )
continue;
if( %sceneObject.getName() $= "" )
continue;
%list = %list TAB %sceneObject.getName();
}
%count = $managedDatablockSet.getCount();
for( %i = 0; %i < %count; %i++ )
{
%object = $managedDatablockSet.getObject( %i );
if( !%object.isMemberOfClass( %objectType ) )
continue;
if( %object.getName() $= "" )
continue;
%list = %list TAB %object.getName();
}
%dbSet = getT2DDatablockSet();
%count = %dbSet.getCount();
for( %i = 0; %i < %count; %i++ )
{
%object = %dbSet.getObject( %i );
if( !%object.isMemberOfClass( %objectType ) || %object.isMemberOfClass( "t2dImageMapDatablock" ) || %object.isMemberOfClass( "t2dAnimationDatablock" ))
continue;
if( %object.getName() $= "" )
continue;
%list = %list TAB %object.getName();
}
%control = %this.createDropDownList(%name, %name, "", %list, %description, true, true);
%listCtrl = %control.findObjectByInternalName(%name @ "DropDown");
%listCtrl.object = %behavior;
}
#11
02/01/2008 (12:07 pm)
I'm going to log this for next release, would be nice to have config datablocks recognizable by behaviors.
Torque 3D Owner Matthew Langley
Torque