API:Sandbox.ModAPI.Ingame.MyGridTerminalSystem

From Space Engineers Wiki
Revision as of 06:39, 13 January 2015 by Textor (talk | contribs) (Moving MyGridTerminalSystem into API namespace.)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

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