Question about using... pickRadius() , pickLine()
by Jesse Hall · in Torque Game Builder · 07/11/2005 (7:47 am) · 11 replies
What would be a basic way of taking the object list from pickRadius() and using it in an IF statement to find a specific type of object from that list?
For example:
gets me something like this : 1235 1238 1239 1244 1245
Id like to find the $player object from this list in order to fire an aggro script. This is my first attempt at an AI and im still new to scripting so any help is appreciated.
- J
For example:
function LiveBot()
// collision object radar
{
echo (t2dSceneGraph.pickRadius( $Bot::Tank1.getPositionX() SPC $Bot::Tank1.getPositionY(), 20 ));
}gets me something like this : 1235 1238 1239 1244 1245
Id like to find the $player object from this list in order to fire an aggro script. This is my first attempt at an AI and im still new to scripting so any help is appreciated.
- J
About the author
#2
you rock man.. thanks!
07/11/2005 (8:43 am)
Crystal clear! I'll rock through the docs on getWordCount =)you rock man.. thanks!
#3
Simsets might be too heavy though?
07/11/2005 (11:05 pm)
That would be cool if these pick functions put their stuff into a simSet instead of a string. Then you could do:if( %objectList.isMember( $player ) )
{
///stuff
}Simsets might be too heavy though?
#4
:-(
An alternative simple test that works for me is:
07/12/2005 (3:39 am)
Quote:One problem with that is that objects can only be in one simset at a time IIRC. If pickRadius() etc.. were to add the object to a (list) simset for return then it would be removed from any set you had put it in
That would be cool if these pick functions put their stuff into a simSet instead of a string.
:-(
An alternative simple test that works for me is:
if( strstr( %list_of_objects, $player ) >= 0 )
{
//etc....
}
#5
Your thinking SimGroups... An object can be in as many SimSets, but only in one SimGroup :)
07/12/2005 (8:10 am)
Quote:One problem with that is that objects can only be in one simset at a time IIRC
Your thinking SimGroups... An object can be in as many SimSets, but only in one SimGroup :)
#6
I like your strstr example though. I'm always wanting to have a nice list of all the script functions for Torque. I keep finding all this cool stuff it can do.
07/12/2005 (8:27 am)
Yeah, ditto on Matt. SimSets are great, I use them as containers all over the place. I like your strstr example though. I'm always wanting to have a nice list of all the script functions for Torque. I keep finding all this cool stuff it can do.
#7
07/12/2005 (8:52 am)
You could easily put the results into a SimSet for later handling. Especially since you're probably going to filter the results anyway, ie, if you're checking for the presence of a certain type of object. As you iterate to compare, plop any positives into a SimSet and then handle them later there.
#9
I should be a fortune cookie.
07/12/2005 (11:11 am)
SimSets are sexy, put all your stuff into them and you will be happy :)I should be a fortune cookie.
#10
07/12/2005 (11:24 am)
Rofl @ justin "the fortune cookie"
#11
07/12/2005 (7:48 pm)
You will be happy until you need the order of the objects in the SimSet to be maintained. Then you will discover some very strange bugs that will take hours to figure out until you realize this. Other than that....... :)
Torque Owner Jason McIntosh
%c = GetWordCount( %list_of_objects ); for ( %i = 0; %i < %c; %i++ ) { %object = GetWord( %list_of_objects, %i ); if ( %object == $player_object ) doStuff(); }Hope that makes the usage clear. :)