Game Development Community

OnTileScript oddness

by Jaybill · in Torque Game Builder · 02/08/2006 (10:47 am) · 8 replies

Okay. I am totally stumped here.

In the tilemap editor, I have specifed some text in the "script" property for a tile. I then have the following code in my game:

function t2dTileMap::onTileScript( %this, %tLayObj, %tXY, %script )
{
  echo("I was totally called. " @ %script);
}

The code never exectutes. Do I have to do anything to tell it to check for scripts? What am I doing wrong? (using beta 1.1)

#1
02/08/2006 (2:01 pm)
I guess the real question here unless I'm missing something super obvious, is how to debug this. When does this callback get made?
#2
02/08/2006 (3:16 pm)
Hi Jaybill!
I'm using alpha4 and this works pretty fine for me.
this echo() "must" to be called if you:
- saved the tiles with the "script" flag enabled
- you are loading the tilemap
- you are loading the layer
- your tiles are show on screen.
This only will be called whenever your tiles appear on screen. and only once.
#3
02/08/2006 (3:21 pm)
@adam - Thanks for the response.

Where is the script flag? I only see a place to enter the "script", but no checkbox or flag or anything. Do you mean by entering data in there, or is there something further I need to do?
#4
02/08/2006 (4:10 pm)
Sorry @Jaybill I misled the physics flag with the script flag.
The only thing needed is to put some code inside the script textbox then.
#5
02/08/2006 (4:14 pm)
Okay, I've done that. Still doesn't work. Herm.

My tilemap is definitely loaded and working and visible, it just won't make that callback.

Do I have the callback set on the correct thing? "t2dTileMap"?
#6
02/08/2006 (4:26 pm)
Okay, I got it now. Collision physics has to be checked and the callback is made only when the tile appears in the window, not when the tile is first loaded into memory. Thanks for the help.
#7
02/08/2006 (4:52 pm)
This is quite weird... I tested this before not exactly in alpha4 but some time ago
maybe alpha2 or 3. Now seems it is not working or I totally forget how to do it. Weird... T2D even
crashed when I was in the tileeditor... hmm hope it wasn't my code. :)
#8
01/22/2009 (8:41 am)
Hi,

Sorry to reopen this thread, but I'm also having trouble with the tile scripts in the latest version (1.7.4)

No matter what I do the onTileScript function is never called.

My tile map (and the tiles with scripts attached) is on the screen and visible when the level is first loaded - I'm wondering if that is my problem.