Game Development Community

Triggers?

by Tim Fox · in Torque Game Engine · 07/21/2005 (3:26 pm) · 9 replies

Ok i understand how todo triggers but when you put in echo it goes to the console how could i put it in the chathud from starter.fps?

#1
07/21/2005 (4:43 pm)
MessageClient?
#2
07/21/2005 (4:51 pm)
Yes, the messageClient, i want my players to enter a dungeon it says IN the messageClient they entered the dungeon?
#3
07/21/2005 (5:30 pm)
Ben is saying that instead of using echo, use the MessageClient functionality. Try looking at how it is used currently, and adapt it to your needs.
#4
07/21/2005 (6:34 pm)
@Tim
I do something like this ,but do some own tests first to learn.
function MessageTrigger::onEnterTrigger(%this,%trigger,%obj)
{
   
   Parent::onEnterTrigger(%this,%trigger,%obj);
   %name = %obj.client.namebase;     
   if (%obj.client)
   messageClient(%obj.client, 'MsgChathud', '\c0 %1 %2',%trigger.nameTag ,%name);

}

when i place the trigger on the map i add the text for the chathud in the nametag field.
#5
07/21/2005 (8:22 pm)
Thanks alot billy!!
#6
07/21/2005 (8:27 pm)
So this is what the whole trigger file should look like?

datablock TriggerData(DungeonTrigger)
{
   tickPeriodMS = 100;
};

//----------------------------------------------------------------

function MessageTrigger::onEnterTrigger(%this,%trigger,%obj)
{
   
   Parent::onEnterTrigger(%this,%trigger,%obj);
   %name = %obj.client.namebase;     
   if (%obj.client)
   messageClient(%obj.client, 'MsgChathud', '\c0 %1 %2',%trigger.nameTag ,%name);

}

//----------------------------------------------------------------

function MessageTrigger::onLeaveTrigger(%this,%trigger,%obj)
{
   
   Parent::onLeaveTrigger(%this,%trigger,%obj);
   %name = %obj.client.namebase;     
   if (%obj.client)
   messageClient(%obj.client, 'MsgChathud', '\c0 %1 %2',%trigger.nameTag ,%name);

}

//put the trigger message in the nameTag field
#7
07/22/2005 (3:19 am)
No datablock TriggerData(DungeonTrigger) must be TriggerData(MessageTrigger)
or change all MessageTrigger to DungeonTrigger.
Like this
datablock TriggerData(DungeonTrigger)
{
   tickPeriodMS = 100;
};

function DungeonTrigger::onEnterTrigger(%this,%trigger,%obj)
{
   
   Parent::onEnterTrigger(%this,%trigger,%obj);
   %name = %obj.client.namebase;     
   if (%obj.client)
   messageClient(%obj.client, 'MsgDungeon', '\c0 %1 %2',%trigger.nameTag ,%name);

}

function DungeonTrigger::onLeaveTrigger(%this,%trigger,%obj)
{
   
   Parent::onLeaveTrigger(%this,%trigger,%obj);
   
}

function DungeonTrigger::onTickTrigger(%this,%trigger)
{
   
   Parent::onTickTrigger(%this,%trigger);
}
#8
07/22/2005 (7:43 am)
Ya i understand and i forgot to excute it thats my main problem.
#9
07/25/2005 (1:19 pm)
What would the code be if i wanted to do another event like Half-Life 2 uses triggers to know when certain monsters should come at the right time and when to save the game?