Exposing custom datablocks and scripted objects in editor
by Norm Koger · in Torque 3D Professional · 10/28/2009 (10:26 pm) · 1 replies
I am trying to create a ShapeBaseData object that parallels some of the functionality of PlayerData. This will be the root of a set of autonomous custom AI controlled game objects. In the process I have created C++ files that more or less duplicate PhysicsPlayer.cpp/h and Player.cpp/h modules including things like calls to IMPLEMENT_CO_DATABLOCK_V1(); as with the player functions. I also have defined a datablock script under art/datablocks as well as an associated server side script file. The free bit 7 slot in objectTypes.h has been reserved for my object type. RegisterGameFunctions() in gameFunctions.cpp has a Con::setIntVariable() line referring to my object type. Near as I can tell, drilling up and down through both the existing scripting and C++ modules, I have pretty much duplicated PlayerObjectType and PlayerData including calls to make the engine aware of the structures.
In the end I _think_ I want to be able to create something a bit like the DefaultCar scripted object using my datablock, but after spending days setting up the datablock associated modules and structures I can't quite see how to do this.
It seems to me that I have two issues.
First, probably the simpler problem: How would I go about creating something identical to the DefaultCar Scripted objects. A literally identical thing similar to DefaultCar, with a different name, would do for my purposes. What files would have to be duplicated, both C++ and scripts? What editor interactions are needed? I don't actually require anything exactly like it for my project, but a guide for creating things like this that can be dropped in the world editor would be very handy.
Second: With the custom data structures described in the opening paragraph, how do I go about exposing my new datablock as a tree selectable option in the Datablock Library of the Datablock editor?
In the end I _think_ I want to be able to create something a bit like the DefaultCar scripted object using my datablock, but after spending days setting up the datablock associated modules and structures I can't quite see how to do this.
It seems to me that I have two issues.
First, probably the simpler problem: How would I go about creating something identical to the DefaultCar Scripted objects. A literally identical thing similar to DefaultCar, with a different name, would do for my purposes. What files would have to be duplicated, both C++ and scripts? What editor interactions are needed? I don't actually require anything exactly like it for my project, but a guide for creating things like this that can be dropped in the world editor would be very handy.
Second: With the custom data structures described in the opening paragraph, how do I go about exposing my new datablock as a tree selectable option in the Datablock Library of the Datablock editor?
About the author
Professional game designer since 1987, with 11 mainstream titles released over the years. M.S. Physics. Software developer for SSI, TalonSoft, and now Storm Eagle Studios.
Associate Steve Acaster
[YorkshireRifles.com]
Copy the relevant scripts and C++ files and then change the AIPlayer/DefaultCar/Whatever to what you want - I used AIEnemy, exec the script in cs file, add the new .cpp and .h files to your project solution and recompile. If I remember correctly it really is that easy.
However, if you just wanted your own type of car - or many cars, you could make a new cs file using the WheeledVehicleData class. Infact you could reference the DefaultCar's data and overwrite pieces of it as you wish this way.
//eg datablock WheeledVehicleData(CustomCar : DefaultCar) { //....extra stuff and different values here //... category = "CustomVehicles"; shapeFile = "art/shapes/customvehicles/mycar.dts"; }Apologies if you knew all the above already.
2. In DefaultCar.cs
category = "Vehicles";
That's how to get stuff into the editor. If it isn't listed as an available folder it will be when you create it in script.