Difference between revisions of "Template:APIStub"

From Space Engineers Wiki
Jump to: navigation, search
m (Protected "Template:APIStub": Reserved to wiki staff only ([Edit=Allow only autoconfirmed users] (indefinite) [Move=Allow only autoconfirmed users] (indefinite)))
(Examples: Added examples for how to use GridTerminalSystem)
Line 5: Line 5:
  
 
== Examples ==
 
== Examples ==
 +
===Search For Single Block With Name===
 
<syntaxhighlight lang="csharp">
 
<syntaxhighlight lang="csharp">
//Examples here
+
void Main()
 +
{
 +
    IMyBeacon beacon = GridTerminalSystem.GetBlockWithName("Beacon"); //beacon is initialized to the first block that is named "Beacon"
 +
}
 +
</syntaxhighlight>
 +
===Search For All Blocks Of Type===
 +
<syntaxhighlight lang="csharp">
 +
void Main()
 +
{
 +
    List<IMyTerminalBlock> blocks = new List<IMyTerminalBlock>();
 +
    GridTerminalSystem.GetBlocksOfType<IMyBeacon>(blocks); //search for all blocks of type "beacon" and put them into the "blocks" list.
 +
}
 +
</syntaxhighlight>
 +
===Search For All Blocks With Part of a Name===
 +
<syntaxhighlight lang="csharp">
 +
void Main()
 +
{
 +
    List<IMyTerminalBlock> blocks = new List<IMyTerminalBlock>();
 +
    GridTerminalSystem.GetBlocksOfName("[Docking]", blocks); //retrieves all blocks with the string [Docking] in the name and puts them into the blocks list.
 +
}
 
</syntaxhighlight>
 
</syntaxhighlight>
  

Revision as of 08:31, 10 January 2015

Template:API

Usage

Examples

Search For Single Block With Name

void Main()
{
     IMyBeacon beacon = GridTerminalSystem.GetBlockWithName("Beacon"); //beacon is initialized to the first block that is named "Beacon"
}

Search For All Blocks Of Type

void Main()
{
     List<IMyTerminalBlock> blocks = new List<IMyTerminalBlock>();
     GridTerminalSystem.GetBlocksOfType<IMyBeacon>(blocks); //search for all blocks of type "beacon" and put them into the "blocks" list.
}

Search For All Blocks With Part of a Name

void Main()
{
     List<IMyTerminalBlock> blocks = new List<IMyTerminalBlock>();
     GridTerminalSystem.GetBlocksOfName("[Docking]", blocks); //retrieves all blocks with the string [Docking] in the name and puts them into the blocks list.
}

Notes