Game Development Community

1.7.2 Adding new datablock in Datablocks.cs

by Teddy Setiawan Wijaya · in Torque Game Builder · 06/15/2008 (11:16 pm) · 8 replies

Hi,

In game/gameScripts/datablocks.cs originally I only have one datablock, later I added two more but how come the last two datablocks do not show up in config datablock list of the level editor?

Did I miss something?

#1
06/16/2008 (4:59 am)
Did you save the script?

I think that the datablocks.cs is called some where in the editor scripts. I've found all the default game scripts like the guiProfiles, datablocks etc to be rather untrustworthy for whatever reason. Many times, code in them will not run in compiled versions. I'd suggest making your own script and executing it in your own way.
#2
06/16/2008 (7:10 pm)
Yes, I did save the script.

Originally, I created my own script then executing the script inside the main.cs project initialization section.
In TGB 1.1.3, this works (I can see and use the datablocks from the level editor).

When I migrated to TGB 1.7.2, somehow it doesn't work anymore.

After reading Fish Demo Tutorial part 8, I got the impression that I have to use datablocks.cs.

To test out, I created one datablock inside the datablocks.cs and I found out that it works (I can see it the level editor).

Therefore I added two more (and save it) but somehow the additional two do not show up in the level editor.

...sigh...
#3
06/16/2008 (7:17 pm)
If you add them while the project is already open in the editor, you can do "reload project" to get them to show up. But it sounds like something else might have happed in your case... You probably just have a syntax error, so it is still using the old dso which only has one datablock.
#4
06/16/2008 (7:31 pm)
James,

I have deleted all the dso files, closed my TGB and then re-opened it.

Here's the code that I put inside the datablocks.cs

exec( "./natalieAnimSets.cs" );
exec( "./yuiAnimSets.cs" );

//------------------------------------------------------------------------------
// Player

datablock t2dSceneObjectDatablock( PlayerConfig )
{
   charName = "Natalie";

   class = "Player";
   superclass = "";

   animationName = Natalie_Idle_South;
   size = "8.000 16.000";
   sortPoint = "0 0.3";

   layer = 10;

  
   isRunning = false;
   isSneaking = false;
   
   isKneelingDown = false;
   isStandingUp = false;
   isStanding = true;
   
   //Stuff for steering
   arriveWeight = 1;
   separationWeight = 2;
   followerWeight = 0;
   avoidanceWeight = 5;
   avoidLeaderWeight = 0;
   shadowingWeight = 0;
   alignmentWeight = 0;
   
   ourPositionAtNearestApproach = "";
   hisPositionAtNearestApproach = "";   
   
   //Movement priority, used in AiGoal during inter character collision 
   movePriority = 1;
   
   graphGroup = 0;
   collisionGroups = BIT(0) | BIT(1) | BIT(2) | BIT(5) | BIT(10);
   CollisionPolyList = "0.639 -0.158 0.600 0.581 -0.613 0.581 -0.613 -0.158";
   Immovable = "1";
   
   // Here we setup a simple collision diamond and prepare
   // the player to recieve as well as dish out collision
   // and physics responses.
   
   collisionResponseMode = CLAMP;
   collisionActiveSend = true;
   collisionActiveReceive = true;
   collisionPhysicsSend = true;
   collisionPhysicsReceive = true;

  
   // The animation sets to use for various states.
   idleAnimsSet = NatalieIdleAnims;
   crouchAnimsSet = NatalieCrouchAnims;
   kneelAnimsSet = NatalieKneelAnims;
   standAnimsSet = NatalieStandAnims;
   runAnimsSet = NatalieRunAnims;
   walkAnimsSet = NatalieWalkAnims;
   sneakAnimsSet = NatalieSneakAnims;
  
   // Stuff we use from script!
   rangeOfSight = 25;
   minTimeToCollision = 3;
   walkSpeed = 25;  //8
   runSpeed = 50;	//25
   sneakSpeed = 10;  //2
   lastDirection = "0 1";
   direction = "0 1";
   lastSpeed = 0;
   
   // Here we set the AI think rate in milliseconds
   // which basicly controls overall reaction time.
   thinkRate = 360;      
};

datablock t2dSceneObjectDatablock( AiPlayerConfig )
{
   class = "AiPlayer";
   superclass = "";
   
   Layer = 10;

   collisionGroups = BIT(0) | BIT(1) | BIT(2) | BIT(5);      
   collisionResponseMode = CLAMP;
   collisionActiveSend = true;
   collisionActiveReceive = true;
   collisionPhysicsSend = true;
   collisionPhysicsReceive = true;      

   /// Here we set the AI think rate in milliseconds
   // which basicly controls overall reaction time.
   thinkRate = 360;   
};

//Yui

datablock t2dSceneObjectDatablock( YuiConfig : AiPlayerConfig )
{
   charName = "Yui";

   graphGroup = 1;   
   
   animationName = "Yui_Idle_West";
   size = "8.000 16.000";
   SortPoint = "-0.032 0.297";
   
   CollisionPolyList = "-0.742 -0.171 0.781 -0.174 0.781 0.535 -0.742 0.535";   
   
   //Stuff for steering
   
   arriveWeight = 1;
   separationWeight = 5;
   followerWeight = 3;
   avoidanceWeight = 5;
   avoidLeaderWeight = 10;
   shadowingWeight = 0;
   alignmentWeight = 1;
   
   ourPositionAtNearestApproach = "";
   hisPositionAtNearestApproach = "";   
   
   //Movement priority, used in AiGoal during inter character collision 
   movePriority = 3;   
   
   distToLeader = 10;
   distToApproachingLeader = 10;
   minTimeToCollision = 5;
   
   // The animation sets to use for various states.
   idleAnimsSet = YuiIdleAnims;
   walkAnimsSet = YuiWalkAnims;
   sitAnimsSet = YuiSitAnims;

   // Stuff we use from script!
   rangeOfSight = 25;
   walkSpeed = 6;
   lastDirection = "-1 0";
   direction = "-1 0";
   life = 100;
   
   isAvoidingLeader = false;
};

datablock t2dSceneObjectDatablock( TreeTriggerConfig )
{
   class = "TreeTrigger";

   // Put this on a special graph
   // group so that we can keep the
   // AI from colliding with it.
   graphGroup = 10;

   // This trigger can only be tripped by
   // the player himself.
   collisionGroups = BIT(0);
   
   enterCallback = true;
   stayCallback = false;
   leaveCallback = true;
   
   //fadeMS = 500;
   fadeMS = 500;
};
#5
06/16/2008 (7:31 pm)
Only the first datablock (PlayerConfig) shows up in the level editor
#6
06/16/2008 (7:46 pm)
Do you have any previous objects/classes, etc named AIPlayerConfig, TreeTriggerConfig . . . . ?
#7
06/16/2008 (8:17 pm)
I found the syntax error. It doesn't like the triple slash comment here:
/// Here we set the AI think rate in milliseconds
   // which basicly controls overall reaction time.
   thinkRate = 360;
I really thought TGB was ok with /// in the past, can anyone confirm if this is a new issue?

BTW Teddy, finding this error is super easy if you are using Torsion. Also you can see the syntax error in the editor's console log itself, it appears pretty prominently right after you do "reload project".
#8
06/16/2008 (9:24 pm)
James,

You are right!!!
I removed the line with triple slash and it works.

TGB 1.1.3 is OK with the triple slash but apparently TGB 1.7.2 is not.

I am using Notepad++ for coding, perhaps I should try Torsion as you suggested.

James, Kevin, thanks for the help