Game Development Community

Another question regarding using "script(when shown):"....

by Christopher Gu · in Torque Game Builder · 11/27/2005 (11:42 am) · 9 replies

Ok, so I now have a tile map which triggers the spawning of enemies on my screen....I set up the enemies in the tile map by using images of the appropriate enemy in a cell and then denoting a function call. The problem that I have now is that when I turn off the visibility on the layer that has the images and triggers of the enemies, the function calls are no longer made!

Just for referance, this is how I set up the layer which contained the enemies:

//layer 3: enemies
%LayerThree = %scrollerMap.getTileLayer( 3 );
%LayerThree.setTileSize( "10 10" );
%LayerThree.setVisible(false);
%LayerThree.setPosition("0 0");
%LayerThree.setWrap( true, false);
%LayerThree.setAutoPan( "400 0" );

When I comment out the line with setVisible() then the enemies spawn at the appropriate time, but the sprites that I used as markers in my tile map show up (I want them to only be visible in the tile editor for level design purposes).

#1
11/27/2005 (12:22 pm)
Christopher,

The tile-layer needs to be visible for scripts to be actioned. This is really a flaw in the temporary tile-editor we use. To help you and others that have this problem, I've generated a task for myself to add the ability to toggle on/off some kind of marker to indicate that a tile contains a script within the engine (C++) and a script-function to control it. I'll also extend the tile-editor so that you can control this feature.

This is issue #0000843

- Melv.
#2
11/27/2005 (12:38 pm)
Hey Melv,

Thank you for the speedy response, I guess I'm not the only one working on Sunday. Ha.

Issue #0000843, eh? ;) Is this something we can expect in the final release of T2D 1.1?

I guess for now I can just design the levels using the markers and then substituting them with blank pixels when the design is finalized. I just wanted to be sure before I went ahead with this.

Thanks again!
#3
11/27/2005 (5:22 pm)
ClearTile() will do the trick.
This will delete the tile and then you call your spawn function.

function fxTileMap2D::onTileScript (%this, %tilelayer, %tilepos, %tilescript)
{
fxTileMap2D.clearTile(%tilepos); //this may have to be the name of your layer
........
}



I use this method in 2 of our games.
#4
11/27/2005 (10:42 pm)
@Christopher: You can expect everything in the T2D v1.1 final release. ;) Seriously though, I'm putting out the internal issue-tracking numbers so that the community has got something real to reference any particular problem by. I'll fix the issues ASAP; things like this one would probably take an hour to do so as soon as I get an hour not occupied with anything else, I'll do it. I normally get the simpler things out of the way first.

- Melv.
#5
11/28/2005 (11:49 am)
Chris-

Excellent, thank you very much for the tip. The syntax that I ended up using was this:

%tilelayer.clearTile(%tilepos);

Quick and painless fix :)

Melv-

Oh wow, I didnt know if you were serious or not with that number you gave me. O_o
#6
11/28/2005 (12:00 pm)
No Prob.
Im glad you got it. Couldnt think of it when i was posted that.
#7
12/03/2005 (6:22 am)
I've resolved Issue #843. Here's the details...

I've added the ability to show icons for both scripts and custom-data as well as being able to specify the icons if you wish.

The new calls are:
%tileLayer.setTileIcons( someImageMap );
%tileLayer.setScriptIconActive( true/false );
%tileLayer.setCustomIconActive( true/false );

"setTileIcons()" allows you to specify an imageMap to use for the icons which allows you to customised them in-case you don't want to use the one that comes with the SDK. It also means that we can extend them as/when we need to show more icons.

"setScriptIconActive()" shows the script icon (at the top-left of the tile) on any tiles that have script assigned.

"setCustomIconActive()" shows the custom-data icon (at the top-right of the tile) on any tiles that have custom-data assigned.


In the following image, the tiles from left to right have custom-data, script and custom-data plus script.
public.garagegames.com/melvm/tileicons.jpg

You can specify you own icons as I mentioned above by assigning your own image-map or changing the one that comes with the tile-editor which looks like:
public.garagegames.com/melvm/tileeditoricons.jpg

Here's an image showing this expose in the editor as a personal preference whether to show the types of icons or not:
public.garagegames.com/melvm/tileiconmenu.jpg

Whilst I was doing this I also fixed-up something that missed the alpha#1 which was changing the tile-edit screen so that the scripts can now be looked-up. If you didn't already know, there's a button below the "custom-data" field which, when pressed, searches all of the current tile-layer and produces a sorted list of all custom-data entries in it (with duplicates removed).

I've also added this ability to the "script" field as well. Also, after you click either of the search buttons (">"), the list with auto-dropdown. It's nice having this ability as it means you can get consistency with your script/custom-data entries. Having this as an explicit search button makes things quicker as this was the main reason why the original SDK was slow with large tile-layers; it searched the list everytime the tile-edit gui appeared!

Anyway, here's an image showing the new screen:
public.garagegames.com/melvm/tiledatascriptselect.jpg

Finally, here's a little movie showing you it working just to it's clear:
Tile-Layer Icons / Script & Custom-Data Search

- Melv.
#8
12/03/2005 (6:24 am)
I just thought I'd also add that I also changed the "getTileScript()" call as it had a pretty big flaw in it. This call returned both the script and a flag indicating whether the script had been actioned as a space-seperated string. This doesn't work very well if the script has spaces in it so I changed this call to return the script only and added another call "getTileScriptActioned()" specifically for returning the actioned status.

- Melv.
#9
12/03/2005 (10:35 am)
Thanks Melv, Thats sweet.