Difference between revisions of "GetBlobsByNameListBlob"

From King Arthur's Gold Wiki
Jump to: navigation, search
(Created page with "<onlyinclude> Returns a reference to a CBlob from the 'Blobs By Name List' with the given index in the list. </onlyinclude> Make sure you call populateBlobsByNameList be...")
 
 
Line 11: Line 11:
  
 
Example from Rules/Scripts/WAR_Players.as:
 
Example from Rules/Scripts/WAR_Players.as:
<syntaxhighlight lang="cpp" highlight="3">
+
<syntaxhighlight lang="cpp" highlight="7">
 
// gather all tents and select assigned team's tent
 
// gather all tents and select assigned team's tent
 
CBlob@ tent;
 
CBlob@ tent;

Latest revision as of 20:10, 20 August 2012

Returns a reference to a CBlob from the 'Blobs By Name List' with the given index in the list.


Make sure you call populateBlobsByNameList before using this function, to ensure the list is up-to-date with the CBlobs of the correct type. Because you're accessing by index number, you'll likely most commonly want to use this for iterating through all of the CBlobs of a particular type - in which case you will also want to use getBlobsByNameListSize to get the number of CBlobs in the list. It may also be useful if you want to get a random or the first CBlob of a particular type.

CBlob@ getBlobsByNameListBlob(int index)

Example from Rules/Scripts/WAR_Players.as:

// gather all tents and select assigned team's tent
CBlob@ tent;
populateBlobsByNameList( "tent" );
 
for (int i=0; i < getBlobsByNameListSize(); i++)
{
  CBlob@ blob = getBlobsByNameListBlob(i);  if (blob.getTeamNum() == assignedTeamNum)
  {	
    @tent = blob; 		
    break;
  }
}