Finding Trigger Types in C++?
by Stefan Beffy Moises · in Torque Game Engine · 07/08/2002 (11:20 pm) · 1 replies
Hi there,
got a quick question: how do I find TriggerObjects in C++?
The "standard way" doesn't seem to find trigger type objects (everything else seems to work well, e.g. InteriorObjectType, ItemObjectType, ...
But this doesn't find anything:
Also, only searching for the className instead of the type doesn't work either, e.g.
Funny thing is, this *does* work in script like this:
Aren't the Triggers in the SimSet? Do I have to use a SimGroup operator and iterate through a different group? But I thought *every* object can be found in the SimSet?
got a quick question: how do I find TriggerObjects in C++?
The "standard way" doesn't seem to find trigger type objects (everything else seems to work well, e.g. InteriorObjectType, ItemObjectType, ...
But this doesn't find anything:
for (SimSetIterator itr(conn); *itr; ++itr) {
if ((*itr)->getType() & TriggerObjectType) {
Con::printf("Found: %s", (*itr)->getClassName());
}...Also, only searching for the className instead of the type doesn't work either, e.g.
for (SimSetIterator itr(conn); *itr; ++itr) {
if (dStrstr((*itr)->getClassName(), "Trigger") != NULL) {
...Funny thing is, this *does* work in script like this:
function getMultiTriggerCount(%name)
{
%dataGroup = "MissionGroup";
%triggerCount = 0;
for(%i = 0; %i < %dataGroup.getCount(); %i++)
{
%obj = %dataGroup.getObject(%i);
if(%obj.getClassName() !$= "Trigger")
{
// no trigger!
continue;
}
if((strStr(%obj.getDatablock().getName(), %name) != -1) && isObject(%obj))
{
echo(%i SPC "Found Trigger:" SPC %obj.getName());
%triggerCount++;
}
}
return %triggerCount;
}Aren't the Triggers in the SimSet? Do I have to use a SimGroup operator and iterate through a different group? But I thought *every* object can be found in the SimSet?
About the author
Associate Stefan Beffy Moises
Stupid /me, of course you have to iterate through the MissionGroup... like it did in script, too... you really shouldn't try to program at 7:00 am ... :-P
SimSet * missionGroup = dynamic_cast<SimSet*>(Sim::findObject("MissionGroup")); for(SimSetIterator itr(missionGroup); *itr; ++itr) { if ((*itr)->getType() & TriggerObjectType) { Con::printf("Found: %s", (*itr)->getClassName()); } }