How to add your custom images to the TileEditor
by Dan Hargrove · in Torque Game Builder · 09/26/2005 (12:46 pm) · 4 replies
Maybe its because I'm stupid and slow, or maybe it's because I'm still learning how to work with T2D, or maybe it's because I can't get to all the official documentation (since I've only purchased the T2D engine), or maybe because its all the above, but I was having trouble trying to figure out how to get my images into the Tile Editor.
For those of you in the same boat - don't make my mistake and try to make too much of it. All you have to do is to define the new datablock(s) in ~\tileeditor\client\datablocks.cs. The engine picks them up automatically. All I did was to add this:
datablock fxImageMapDatablock2D(BlueBrickImageMap)
{
mode = full;
textureName = "~/client/images/BlueBrickTwo"; //or whatever your file name is
};
and all was right with the world (the variable name you use in the fxImageMapDatablock2D constructor is what shows up in the library list).
It may seem silly to those of you that have been around T2D for a while, but I only figured this out trying to see what affect it would have. This is even after all the searching through the threads. There was a thread or two saying that you needed to create your own datablock, but dummy me didn't put two and two together on adding it to this file until just now.
So, in order to hopefully save time for others, I thought I'd spell it out specifically.
-Dan
For those of you in the same boat - don't make my mistake and try to make too much of it. All you have to do is to define the new datablock(s) in ~\tileeditor\client\datablocks.cs. The engine picks them up automatically. All I did was to add this:
datablock fxImageMapDatablock2D(BlueBrickImageMap)
{
mode = full;
textureName = "~/client/images/BlueBrickTwo"; //or whatever your file name is
};
and all was right with the world (the variable name you use in the fxImageMapDatablock2D constructor is what shows up in the library list).
It may seem silly to those of you that have been around T2D for a while, but I only figured this out trying to see what affect it would have. This is even after all the searching through the threads. There was a thread or two saying that you needed to create your own datablock, but dummy me didn't put two and two together on adding it to this file until just now.
So, in order to hopefully save time for others, I thought I'd spell it out specifically.
-Dan
#2
Did you get any error-messages in your console.log that might be relevant?
--
Hans
10/17/2005 (11:57 pm)
No tutorial that I know of, but what you did is pretty much it.Did you get any error-messages in your console.log that might be relevant?
--
Hans
#3
//start code fragment
datablock fxImageMapDatablock2D([UniqueName]ImageMap)
{
mode = cell;
cellWidth = 32; // your tile width
cellHeight = 32; // your tile height
textureName = "~/client/images/[YourImageNameWithoutExtension]";
};
//end code fragment
Change [UniqueName] to what you want to show up in the Image Library list. It must be unique to the other names used in datablocks.cs.
Change [YourImageNameWithoutExtension] to the name of your image, without the extension.
If you use a different cell size than 32x32, change cellWidth and cellHeight accordingly.
Remember to delete your datablocks.cs.dso file before running T2D. I run T2D from a batch file located in the same directory as T2D.exe, as follows:
rem start batch file
@echo off
del /S /F /Q *.dso
T2D.exe
rem end batch file
There's probably a way to reload datablocks.cs from within T2D, but I never took the time to figure it out. :)
11/05/2005 (10:23 am)
Matthews, try this in your datablocks.cs file://start code fragment
datablock fxImageMapDatablock2D([UniqueName]ImageMap)
{
mode = cell;
cellWidth = 32; // your tile width
cellHeight = 32; // your tile height
textureName = "~/client/images/[YourImageNameWithoutExtension]";
};
//end code fragment
Change [UniqueName] to what you want to show up in the Image Library list. It must be unique to the other names used in datablocks.cs.
Change [YourImageNameWithoutExtension] to the name of your image, without the extension.
If you use a different cell size than 32x32, change cellWidth and cellHeight accordingly.
Remember to delete your datablocks.cs.dso file before running T2D. I run T2D from a batch file located in the same directory as T2D.exe, as follows:
rem start batch file
@echo off
del /S /F /Q *.dso
T2D.exe
rem end batch file
There's probably a way to reload datablocks.cs from within T2D, but I never took the time to figure it out. :)
#4
This means that you can create you game using either a new base or use the existing T2D one, define your datablocks and go into any of the editors and the datablocks are available.
The reason I say this is so that you don't think you've got to specifically put your datablock definitions in the editor mod datablock files. When you release your game, you'll be deleting these directories (or in the new packaging utility, it simply won't package that stuff).
If you look at the script-code for the editors, you'll see that nothing clever is going on really. All it does is look through the list supplied by the T2D call "getDatablockSet2D()". This is just a standard script SimSet. The editors go through this list looking for objects that are of the type "fxImageMapDatablock2D".
The good news is that I wrote a comprehensive 30-page document detailing the new image-map system and all it's parameters with plenty of examples/images. Some of the stuff in the earlier releases is definately ambiguous; hopefully we've rectified that in the new release.
Hope this helps,
- Melv.
11/06/2005 (1:20 am)
Just to be clear; there's no need to define your datablocks in any specific location, especially not "~\tileeditor\client\datablocks.cs". As long as your datablocks are defined, they'll be available everywhere.This means that you can create you game using either a new base or use the existing T2D one, define your datablocks and go into any of the editors and the datablocks are available.
The reason I say this is so that you don't think you've got to specifically put your datablock definitions in the editor mod datablock files. When you release your game, you'll be deleting these directories (or in the new packaging utility, it simply won't package that stuff).
If you look at the script-code for the editors, you'll see that nothing clever is going on really. All it does is look through the list supplied by the T2D call "getDatablockSet2D()". This is just a standard script SimSet. The editors go through this list looking for objects that are of the type "fxImageMapDatablock2D".
The good news is that I wrote a comprehensive 30-page document detailing the new image-map system and all it's parameters with plenty of examples/images. Some of the stuff in the earlier releases is definately ambiguous; hopefully we've rectified that in the new release.
Hope this helps,
- Melv.
Torque Owner Matthews_30
i have a png map so i divide it in 32x32 tiles (250 tiles!)
rename the old images folder
copy my tiles folder and rename it to "images"
i used the datablock tool to create the datablock.cs wich makes the same script modification you say.
rename the old datablocks.cs
copy my own datablocks.cs (from the tool and with the same sintax you have here)
it did not work :(
is there a tutorial to make this?