Author Topic: Objects in a box?  (Read 1413 times)

How would I perform code on all objects within an arbitrary rectangular shape?

I ask because in a game like blockland, using getTransform() and then a condition on every object in the mission simply isn't feasible.

Quote from: Badspot
Code: [Select]
initContainerBoxSearch(%position, %boxSize, %mask);
while (%searchObj= containerSearchNext())
{
   //do stuff to %searchObj
}

 :cookie:

can you tell me what the parameters mean? (i.e. is position from one corner or the center, how is boxsize measured, is mask things to ignore or things to find, taking only one object or datablocks, etc.)
« Last Edit: September 16, 2007, 09:32:17 PM by Mr. Wallet »

%boxsize is "x y z" in torque units, %position is the exact center of the box. %mask is the typemask/s of whatever object type/s you want to look for. possible typemaks are $typemasks::fxbrickobjecttype, $typemasks::playerobjecttype, $typemasks::vehicleobjecttype, etc. you can just type $typemasks:: in the console and hit tab to see them all ;)

Code: [Select]
initContainerBoxSearch(%obj.getposition(),"3 3 3",$typemasks::fxbrickobjecttype);
while(%target=containersearchnext()){
 echo(%target);
}
this would echo the id of every brick in a 3x3x3 box around %obj ;)

edit: if you want to search for more than one typemask, just put a | between them, ex. $typemasks::fxbrickobjecttype | $typemasks::playerobjecttype | $typemasks::vehicleobjecttype
« Last Edit: September 16, 2007, 09:47:22 PM by Zor »