We're giving away 4 copies of V Rising to 4 editors of the V Rising Wiki. Simply create an account and contribute! See more details here Wiki Contest.

API:Sandbox.ModAPI.Ingame.MyGridTerminalSystem

From Space Engineers Wiki
Revision as of 04:47, 25 February 2015 by Blop (talk | contribs) (Example of 1.4.3.SearchBlocksOfName was not updated)
(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.SearchBlocksOfName("[Docking]", blocks); //retrieves all blocks with the string [Docking] in the name and puts them into the blocks list.
}