Game Development Community

SetTileCustomData and the Map Editor

by Jacob Vann · in Torque Game Builder · 10/21/2005 (8:33 pm) · 3 replies

Hey Guys -

Not sure where this thread should go, since I'm not sure where the problem is.

The map editor doesn't seem to be saving Tile map custom data. I'm using the custom data field for tiles and a special "meta" tile layer for tiles that are above the doors and store information about the adjoining room.

I add the tiles through the map editor, and ctrl-click them and add the custom data. However, after saving and reloading, I can't see the custom data.

Moreover, in my code, the custom data field seems to be empty.

Here's a snippet of my onCollision() function:

if (%dstObj.getGroup() == $metaTileGroup) {
    	// load the data from the tile and spit it out
    	// get the tile location:
    	%tileposx = getWord(%dstRef, 0);
    	%tileposy = getWord(%dstRef, 1);
    	%metadata = %dstObj.getTileCustomData(%tileposx SPC %tileposy);
    	echo ("======> "SPC %tileposx SPC %tileposy SPC %metadata);
}

I know that I'm colliding with the correct tiles, as I don't get any printouts until I am colliding. However, the %metadata variable isn't getting set at all, and I think it's that the map editor is not saving this data correctly.

I added this line in the above conditional block:
%dstObj.setTileCustomData(%tileposx SPC %tileposy, "This is a test.");

And sure enough, at every iteration after 1, I get output that I would expect ("this is a test.");

Has anyone else had luck setting tile custom data through the editor and retrieving it in script? Any advice?

... on a side-note, does anyone have an elegant solution for linking multiple maps together, where when the player reaches the boundary of one map he is placed in the adjoining map (like a screen-by-screen RPG, or an adventure game with multiple corridors)?

I'm basically treating my rooms as nodes in a big linked-graph, where each "room" can connect to any other "n" rooms, and the doorways between rooms have some "meta" data that stores the filename for the next room, and the relative position of the doorway in the next room. When the player collides with the doorway "meta" tiles, the meta data is bound to him, and then whenever he reaches the edge of the room I'll use it to load the new map and shift the player's position.

It works in theory, but so far I'm wrestling with the mechanics of T2d in getting at the data.

Any help is VERY much appreciated.

#1
10/22/2005 (12:40 am)
The custom tile data (as you've found) doesn't work, but it's been discussed several times and there is a solution to fix it. It requires some engine changes but a search should turn up the relevant info.
#2
10/22/2005 (10:27 am)
I'm sorry for not searching earlier.

But this is rather discouraging. I don't want to change the engine code in order to make it work, because those changes will essentially either break my script code in the next version, or will need to be somehow carried over.

I did see a post from Melv back in March that this "was fixed", and he followed up by saying that since it breaks the file format, we will have to wait for the next release. Is this issue fully addressed in 1.1, then?

Perhaps it's time I pour my coding into making a map editor specific to my game in the meantime. Thanks for the help.
#3
10/23/2005 (11:49 am)
You find that the code is already there, you simply have to uncomment a couple of lines in the code.

The reason it wasn't put in was that we didn't want to break existing tile-maps without a better solution for the file load/saves. It's fully addressed in the version you've got, you just have to simply make those changes.

Search for the comments "Will be added in when new file-format is ready." and uncomment the lines it appears on and it'll work fine for you.

Hope this helps,

- Melv.