Game Development Community

"Creating a Datablock" tutorial question

by Vaughan Greer · in Torque Game Builder · 03/18/2009 (12:51 am) · 6 replies

Hey all. I'm going through the tutorials trying to learn how to use TGB with the trial version before I buy it, and I hva ebeen working on the "Tutorials-Feature-Config Datablocks" tutorial for about an hour now. In the tutorial I was told to create a configs.cs file in my gamescripts folder containing the catablock info, which in this tutorial was the following:

datablock t2dSceneObjectDatablock(TestConfig)
{
Layer = 1;
Size = "100 100";
};

So after this I'm supposed to add the following lines of code to my main.cs file:

//exec config datablocks
exec("./gameScripts/configs.cs");

right above the line "//exec game scripts" and supposedly this would allow me to select an item in TGB, go to the edit tab under Scripting and select my Datablock from the Config Datablock pulldown menu. Unfortunately this never *ever* worked. I checked and double checked and quadrouple checked my steps and I couldn't get any datablocks to appear in that damn pulldown menu!

Just as I'm about to give up I notice that in my /gamescripts folder there's *already* a text document called 'datablocks'. So I open it up and this is what it says...

//---------------------------------------------------------------------------------------------
// 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.
//


Hrmmm 'Custom Datablocks' eh? that sounds a lot like what I've been trying to do for the last hour. So on a lark I post the text from my configs.cs file into this 'datablocks' file, restart TGB and when I select a sprite and go to Edit->Scripting->Config Datablock there's my Datablock right there in the pulldown!

So what gives? Is this an outdated tutorial? Or am I still doing something wrong?

About the author

Recent Threads


#1
03/20/2009 (10:53 pm)
You are completely right, it's a slightly outdated tutorial, At one point TGB's engine and editors were in a single executable, since then (as you can see) the editor and game .exe's have been split out, this means the editor needed a way to load your game datablocks so it can load them into the editor, hence the creation of an automatically exec'd datablocks.cs.

I'm glad you found the solution and sorry you had to struggle. Config Datablocks can be very useful :)
#2
03/21/2009 (12:33 pm)
Thanks for catching this. I will amend the TGB tutorials during my next round of updates.
#3
06/09/2009 (7:36 pm)
when I put the code below into datablocks.cs and try to compile i get an error saying

"unable to instantiate non-conobject class FlyingVehicleData".

I grabbed this code from the torque developer network forum,
and I've looked at a few other examples, written different ways and none of them seem to work for me when i test.

I'd just like to know the proper syntax to create a datablock.

thanks

//

datablock FlyingVehicleData(F117NighthawkBlock)
{
category = "Vehicles";
mass = 60;

//... more fields describing this type of aircraft.
};

//
#4
06/09/2009 (8:04 pm)
FlyingVehicleData is from our 3D engines, TGE and TGEA.
#5
06/17/2009 (5:00 pm)
okay, I've figured out how to write a datablock for TGB and not have it throw any syntax errors, but now I'm getting an error saying that my image is invalid. My image is in that folder and it's a png. Any help would be appreciated.

Thanks,


CODE:

datablock t2dImageMapDatablock(sumoWhiteDB)
{
imageName = "../game/data/images/sumoWhiteImageMap";
imageMode = "FULL";
};

ERROR:

'Invalid Bitmap !' (2)
#6
09/01/2009 (7:49 pm)
Awesome!!

It's urgent to update that tutorial.

Thanks.