Difference between revisions of "API:Sandbox.ModAPI.Ingame.MyGridTerminalSystem"

From Space Engineers Wiki
Jump to: navigation, search
(Moving MyGridTerminalSystem into API namespace.)
 
m (Example of 1.4.3.SearchBlocksOfName was not updated)
 
Line 53: Line 53:
 
{
 
{
 
     List<IMyTerminalBlock> blocks = new List<IMyTerminalBlock>();
 
     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.
+
     GridTerminalSystem.SearchBlocksOfName("[Docking]", blocks); //retrieves all blocks with the string [Docking] in the name and puts them into the blocks list.
 
}
 
}
 
</syntaxhighlight>
 
</syntaxhighlight>
  
 
[[Category:API]][[Category:Programmable Block]][[Category:Sandbox.ModAPI.Ingame]]
 
[[Category:API]][[Category:Programmable Block]][[Category:Sandbox.ModAPI.Ingame]]

Latest revision as of 04:47, 25 February 2015

Sandbox.ModAPI.Ingame.MyGridTerminalSystem

MyGridTerminal system is a special class provided by Keen for use in the programmable block's scripting editor. It is used to interface with all blocks on the local grid and any connected grids. This class will be used at least once by all scripts.

Namespace

Sandbox.ModAPI.Ingame

Assembly

Sandbox.Common (Sandbox.Common.dll)

Syntax

public MyGridTerminalSystem

Methods

GetBlocksOfType

void GetBlocksOfType<T>(List<IMyTerminalBlock> blocks, Func<IMyterminalBlock, bool> collect = null)

GetBlockWithName

IMyTerminalBlock GetBlockWithName(string name)

SearchBlocksOfName

void SearchBlocksOfName(string name, List<IMyTerminalBlock> blocks, Func<IMyTerminalBlock, bool> collect = null)

Properties

BlockGroups

List<IMyBlockGroup> BlockGroups {get;}

Blocks

List<IMyTerminalBlock> Blocks {get;}

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.SearchBlocksOfName("[Docking]", blocks); //retrieves all blocks with the string [Docking] in the name and puts them into the blocks list.
}