Datablock Problem and SimSet Syntax error...
by Ecliptic · in Torque Game Builder · 12/09/2008 (10:25 am) · 7 replies
I have been trying to create a datablock for an t2dSceneObject that will have the same class, properties, ect with the only difference being the frame assigned to it. I am having several problems currently with the builder accepting my configs and creating a new object from a simSet. I have created two datablocks in my datablocks.cs file initializing several values. I have tested it through echo commands in the build to make sure it was collecting the data and storing it. So I believe the code is working as intended but when I go and assign them the the Config Datablock tab under scripting to the actual ImageMaps I want it to affect nothing happens. They don't use any of the values assigned in the datablocks and when I add more of the same ImageMaps it resets the Config Datablock to nothing. I was reading the References and it stated that from now on when I dragged in the file it should retain the Config data.. Has this been changed? If not here is my code for the datablocks and maybe there is something wrong with it?
This is my simSet code that I can't figure out what the syntax error is... I have named the Scenegraph in the project file to BeginnerLevel and the two SceneObjects are defined in the datablocks posted above... Anyone can help guide me to a solution? Or a source I can read to try and figure out what I have done wrong. I am not asking anyone to write it for me, I just need some help. I know I have been posting a lot lately but I am truely trying and don't want to be that annoying person who doesn't "search" for answers. Believe me I have been searching ALOT.
I am going to be working on it all day tomorrow as well. So any help will definitely be appreciate. Thanks in advance guys and once again I am sorry for the questions.
Thanks
Dane
datablock t2dSceneObjectDatablock (BlocksImageMap)
{
myField = "BlockField";
imageName = "game/data/images/blocks";
imageMode = cell;
cellWidth = 54;
cellHeight = 54;
cellCountX = 4;
cellCountY = 4;
class = BlockClass;
layer = 1;
};
datablock t2dSceneObjectDatablock (SpawnsImageMap)
{
myField = "SpawnField";
imageName = "game/data/images/spawns";
imageMode = FULL;
class = spawnPoint;
};This is my simSet code that I can't figure out what the syntax error is... I have named the Scenegraph in the project file to BeginnerLevel and the two SceneObjects are defined in the datablocks posted above... Anyone can help guide me to a solution? Or a source I can read to try and figure out what I have done wrong. I am not asking anyone to write it for me, I just need some help. I know I have been posting a lot lately but I am truely trying and don't want to be that annoying person who doesn't "search" for answers. Believe me I have been searching ALOT.
//This is the Scenegraph information to specify which level is being loaded.
function BeginnerLevel::onLevelLoaded(%this)
{
%this.spawnPointSet = new SimSet();
}
function BeginnerLevel::onLevelEnded(%this)
{
%this.spawnPointSet.delete();
}
//Create a Block using the spawn locations provided.
function BeginnerLevel::spawnBlock(%this)
{
//Find a random spawn spot that is not occupied.
%spawnPointIndex = getRandom( %this.spawnPointSet.getCount()-1 );
%spawnPoint = %this.spawnPointSet.getObject( %spawnPointIndex );
//Created the block then make sure it is in the correct spot.
%blockClass = new t2dSceneObject()
{
SceneGraph = BeginnerLevel;
class = BlockClass;
}
%BlockClass.getPosition( %spawnPoint.Position() );
}I am going to be working on it all day tomorrow as well. So any help will definitely be appreciate. Thanks in advance guys and once again I am sorry for the questions.
Thanks
Dane
#2
**** being what ever field I wanted it to repeat back to me. The game seems to hold all the information I wanted it to, so I am assuming it works correctly. But if I create a size field (Size = "15 15";) then it produces a syntax error. I also tried (Size = "15.0 15.0";).
I believe maybe I am not using the datablocks correctly? I am trying to create a datablock from an t2dImageMap but I am trying to create a t2dSceneObject. Are you able to use a t2dImageMap as a scene object? I am still digging through the references and maybe I misunderstood something about scene objects?
Thanks for the help Neo.
Dane
12/09/2008 (11:41 am)
I tried adding the semi-colon with no success... I thought {} did not require semi-colons so I will go back and check all my scripts and see if that helps. My other concern is when I add the config data to the imagemaps in the editor they don't automatically apply themselves when I drag another of the same image in. I was checking to make sure my datablocks were working by running this durring the build.echo (blockImageMap.*****);
**** being what ever field I wanted it to repeat back to me. The game seems to hold all the information I wanted it to, so I am assuming it works correctly. But if I create a size field (Size = "15 15";) then it produces a syntax error. I also tried (Size = "15.0 15.0";).
I believe maybe I am not using the datablocks correctly? I am trying to create a datablock from an t2dImageMap but I am trying to create a t2dSceneObject. Are you able to use a t2dImageMap as a scene object? I am still digging through the references and maybe I misunderstood something about scene objects?
Thanks for the help Neo.
Dane
#3
Sorry forgot to add: image maps can't be added to a scene, you
need a scene object derived class so you can use e.g t2dStaticSprite:
Or you can preload all the settings (which perhaps is what youre trying to do)
into a t2dSceneObjectDatablock() and assign that to e.g. a t2dStaticSprite.config field
12/09/2008 (12:01 pm)
You initial datablocks seem to be imageMaps so should be declared as:new t2dImageMapDatablock(BlocksImageMap)
{
myField = "BlockField";
imageName = "game/data/images/blocks";
imageMode = cell;
cellWidth = 54;
cellHeight = 54;
cellCountX = 4;
cellCountY = 4;
class = BlockClass;
layer = 1;
};
new t2dImageMapDatablock(SpawnsImageMap)
{
myField = "SpawnField";
imageName = "game/data/images/spawns";
imageMode = FULL;
class = spawnPoint;
};Sorry forgot to add: image maps can't be added to a scene, you
need a scene object derived class so you can use e.g t2dStaticSprite:
%this.testSprite = new t2dStaticSprite()
{
scenegraph = sceneWindow2D.getSceneGraph();
imageMap = Rohan5ImageMap;
...
};Or you can preload all the settings (which perhaps is what youre trying to do)
into a t2dSceneObjectDatablock() and assign that to e.g. a t2dStaticSprite.config field
#4
I have narrowed the section that is causing the error to.
Everything before this gives no error. Once I add this section of code I get the error.
I changed the datablocks to the correct declaration but I am still getting the same error. I have also changed that section to create a new t2dImageMap rather than a t2dSceneObject. Is there a way I can setup a fuction I can call in the command line to create an object from my datablock to test while the game is running? Maybe there is something else I need to define that I have not defined?
Thanks again,
Dane
12/09/2008 (12:16 pm)
What is the actual difference between a t2dSceneObject and a t2dImageMap? Is a sceneObject an actual OBJ file? I was thinking a SceneObject was something in the scene that was affected through code vs an Image that was static.I have narrowed the section that is causing the error to.
//Created the block then make sure it is in the correct spot.
%blockClass = new t2dImageMap()
{
SceneGraph = BeginnerLevel;
class = BlockClass;
}
%BlockClass.getPosition( %spawnPoint.Position() );
};Everything before this gives no error. Once I add this section of code I get the error.
I changed the datablocks to the correct declaration but I am still getting the same error. I have also changed that section to create a new t2dImageMap rather than a t2dSceneObject. Is there a way I can setup a fuction I can call in the command line to create an object from my datablock to test while the game is running? Maybe there is something else I need to define that I have not defined?
Thanks again,
Dane
#5
edit: You only need it after the datablock closing brace, NOT all braces - the datablock declaration is a statement and so has to be closed with a semi-colon.
A t2dImageMap is just a way to reference a bitmap image, it doesnt DO anything really. To see anything in a scene you need a scene object, i.e. t2dStaticSprite or t2dAnimatedSprite, t2dTileMap, etc, each of which uses image maps.
12/09/2008 (12:23 pm)
Try adding the semi-colon after the datablock closing brace like I said, I tested it and that does the trick ;pedit: You only need it after the datablock closing brace, NOT all braces - the datablock declaration is a statement and so has to be closed with a semi-colon.
A t2dImageMap is just a way to reference a bitmap image, it doesnt DO anything really. To see anything in a scene you need a scene object, i.e. t2dStaticSprite or t2dAnimatedSprite, t2dTileMap, etc, each of which uses image maps.
#6
I am now getting no errors but it is saying
I am guessing this is what you are talking about in the earlier post since an ImageMap is just a reference. I will work on this and come back if I have any problems. I appreciate the help, it cleared up a lot. From now on I will pay closer attention to my datablocks =).
Thanks again Neo.
Dane
12/09/2008 (12:47 pm)
Thanks a million Neo! That did the trick for the syntax error.I am now getting no errors but it is saying
t2dStaticSprite::setFrame() - Cannot set Frame without existing t2dImageMapDatablock Datablock!
I am guessing this is what you are talking about in the earlier post since an ImageMap is just a reference. I will work on this and come back if I have any problems. I appreciate the help, it cleared up a lot. From now on I will pay closer attention to my datablocks =).
Thanks again Neo.
Dane
#7
12/09/2008 (12:57 pm)
Glad you got it working, good hunting ;p
Torque Owner Neo Binedell