Game Development Community

Dynamically adding objects / datablocks

by Orion Elenzil · in Torque Game Engine · 08/23/2004 (12:34 pm) · 2 replies

Hi All.

This thread may belong in a more advanced forum,
but i'll try it out here.

So i'd like to be able to drag-and-drop a resource,
say a .dts file, onto the torque window
and have the object be instanciated in the game.

I've got the drag-n-drop going thru to a script function, eg:
function addFile(%theFile)
{ ... }

How would i have addFile() create a new ItemData datablock ?

Would i need to do something like construct a string
which contains the syntax for a new datablock and eval() the string ?

Also,
am i correct in understanding that i can't do something like this:

//-----------------------------------------------
%shapeFile1 = "some dts file";
%shapeFile2 = "some other dts file";

datablock ItemData(justAStaticShape)
{ };

%newShape1 = new Item()
{
datablock = justAStaticShape;
};
%newShape1.datablock.shapeFile = %shapeFile1;

%newShape2 = new Item()
{
datablock = justAStaticShape;
};
%newShape2.datablock.shapeFile = %shapeFile2;

//-----------------------------------------------

- that is,
i can't use the same datablock for two different .dts files.


many thanks in advance,
Orion

#1
08/23/2004 (12:46 pm)
I'm not real sure what you're asking here, but I'll comment on what I do. Yes, the same datablock can be used with numerous .dts files. Players do this, at least in RW. And you can construct at least part (maybe all) of the datablock on the fly. I'm not real sure how atm, but you should be able to find what you need in the objectbuilder* section of the editor.
#2
08/23/2004 (1:53 pm)
[edited]

Thanks erik.
the objectbuilder source code looks useful.

this will show exactly how new i am,
but how do i get to the object builder
in the runtime app ?

- is it the tree controls in the right hand side
of the World Editor Inspector etc ?