Game Development Community

Noob script question

by Jeff LaFlam · in Torque Game Engine · 04/11/2007 (2:39 pm) · 0 replies

Hi All,

I've created a new test object in the engine called SampleObject that has an event called onTrapMe. I then create a new object in the script and try to catch it's event. I have no problem doing this but if I create multiple of these objects in my script how can I distinguish between them when catching the event.

Here is my sample script: this works btw

$test = new SampleObject();
$test.MemberTest(); <--this will trigger the OnTrapMe event


function SampleObject::onTrapMe(%this)
{
echo("in event");
}


If I have multiple SampleObjects and I want to have a different onTrapMe event handler for each how do I do that?

This is what I was thinking but it doesn't work:

new SampleObject(test1);
new SampleObject(test2);
test1.MemberTest();
test2.MemberTest();

function test1::onTrapMe(%this)
{
echo("in event test1");
}

function test2::onTrapMe(%this)
{
echo("in event test2");
}

neither event is caught of course...I think I'm missing something really basic here. Any help would be greatly appreciated.

About the author

Recent Threads

  • Duplicate cursor