Create() called by editor.cs for creating new datablocks
by CSUMB (#0032) · in Torque Game Engine · 02/21/2005 (7:39 pm) · 2 replies
Hi,
I have a quick question. I'm looking at the code-sample tutorial for
creating a dataItem and colliding with it (superbomb example).
I notice that when you implement the method "create()" it is associated
with the datablock, and not the superbomb. (see below)
Why can't I assosicate "create" with SuperBomb. When I try this
I can an error message that the "Editor.cs" unable to find ItemData.create().
If I can't associate this with "SuperBomb" instead of ItemData, then
how can I have more than 1 type of ItemData that I can insert into
mission via the editor?
-Michael
------------------------------------------------------------------------------------
datablock ItemData( SuperBomb )
{
category = "Bombs";
shapeFile = "~/data/shapes/superbomb/superbomb.dts";
};
function ItemData::create( %data )
{
echo( "ItemData::create for SuperBomb called" );
%obj = new Item()
{
dataBlock = %data;
};
}
I have a quick question. I'm looking at the code-sample tutorial for
creating a dataItem and colliding with it (superbomb example).
I notice that when you implement the method "create()" it is associated
with the datablock, and not the superbomb. (see below)
Why can't I assosicate "create" with SuperBomb. When I try this
I can an error message that the "Editor.cs" unable to find ItemData.create().
If I can't associate this with "SuperBomb" instead of ItemData, then
how can I have more than 1 type of ItemData that I can insert into
mission via the editor?
-Michael
------------------------------------------------------------------------------------
datablock ItemData( SuperBomb )
{
category = "Bombs";
shapeFile = "~/data/shapes/superbomb/superbomb.dts";
};
function ItemData::create( %data )
{
echo( "ItemData::create for SuperBomb called" );
%obj = new Item()
{
dataBlock = %data;
};
}
About the author
#2
when the "Editor" calls create(), how does it know what to create exactly?
Or in other words, does the editor pass the name of whatever you clicked on in the creator
panel to the create function?
If not, how does it know which item to create?
Thanks! and sorry for bringing this thread back...
03/20/2007 (5:51 pm)
Sorry to bring this back from the dead, but I just want to be clear about something.when the "Editor" calls create(), how does it know what to create exactly?
Or in other words, does the editor pass the name of whatever you clicked on in the creator
panel to the create function?
If not, how does it know which item to create?
Thanks! and sorry for bringing this thread back...
Associate Manoel Neto
Default Studio Name
The %data in ItemData::create(%data) is actually a reference to your newly born datablock (that has just spawned off ItemData).
To make the bomb appear in the mission editor, you only need to use the "category" field. Type something in there and the datablock will be listed inside the "Shapes" category in the mission editor.
In your case, your superBomb is in shapes > Bombs in the mission editor.