Difference between revisions of "Programmable Block"
(+added character limit) |
|||
Line 47: | Line 47: | ||
Programmable Block scripts run in a single update (single frame) and any that take too long to complete are aborted. This means it is impossible for a single run of the script to 'wait' on any event. If you want your script to run when something happens, you need to either find a way of getting another block to trigger it at the right time (an 'interrupt-driven' approach via eg. a sensor block), or modify your script to check for a precondition and set up a timer to run it regularly (a 'polling' approach). Depending on what your script is doing, one approach may be the preferred or even the only way to do it. | Programmable Block scripts run in a single update (single frame) and any that take too long to complete are aborted. This means it is impossible for a single run of the script to 'wait' on any event. If you want your script to run when something happens, you need to either find a way of getting another block to trigger it at the right time (an 'interrupt-driven' approach via eg. a sensor block), or modify your script to check for a precondition and set up a timer to run it regularly (a 'polling' approach). Depending on what your script is doing, one approach may be the preferred or even the only way to do it. | ||
+ | |||
+ | Since [[Update 01.067]] each programmable block has a maximum limit of 50,000 characters for any in-game script. | ||
== API List == | == API List == |
Revision as of 18:36, 31 October 2015
A Programmable Block can be programmed to do different functions, like switching lights and controlling doors. It can also be used by entering the control panel in the Terminal. It has almost unlimited functionality. One of the biggest problems is that variables are not saved between world exit and loading.
Programmable Block scripts run in a single update (single frame) and any that take too long to complete are aborted. This means it is impossible for a single run of the script to 'wait' on any event. If you want your script to run when something happens, you need to either find a way of getting another block to trigger it at the right time (an 'interrupt-driven' approach via eg. a sensor block), or modify your script to check for a precondition and set up a timer to run it regularly (a 'polling' approach). Depending on what your script is doing, one approach may be the preferred or even the only way to do it.
Since Update 01.067 each programmable block has a maximum limit of 50,000 characters for any in-game script.
Contents
- 1 API List
- 2 Action List
- 2.1 Antenna
- 2.2 Arc Furnace
- 2.3 Artificial Mass
- 2.4 Assembler
- 2.5 Battery
- 2.6 Beacon
- 2.7 Button Panel
- 2.8 Camera
- 2.9 Cockpit
- 2.10 Collector
- 2.11 Connector
- 2.12 Control Panel
- 2.13 Control Station
- 2.14 Door
- 2.15 Drill
- 2.16 Flight Seat
- 2.17 Gatling Turret
- 2.18 Gravity Generator
- 2.19 Grinder
- 2.20 Gyroscope
- 2.21 Interior Light
- 2.22 Interior Turret
- 2.23 Landing Gear
- 2.24 Small Cargo Container
- 2.25 Medium Cargo Container
- 2.26 Large Cargo Container
- 2.27 Small Reactor
- 2.28 Large Reactor
- 2.29 Small Thruster
- 2.30 Large Thruster
- 2.31 Medical Room
- 2.32 Merge Block
- 2.33 Missile Turret
- 2.34 Ore Detector
- 2.35 Passenger Seat
- 2.36 Piston
- 2.37 Programmable block
- 2.38 Refinery
- 2.39 Spotlight
- 2.40 Remote Control
- 2.41 Rocket Launcher
- 2.42 Reloadable Rocket Launcher
- 2.43 Rotor
- 2.44 Sensor
- 2.45 Solar Panel
- 2.46 Sound Block
- 2.47 Spherical Gravity Generator
- 2.48 Timer Block
- 2.49 Warhead
- 2.50 Welder
- 2.51 Wheel Suspension 1x1
- 2.52 Wheel Suspension 3x3
- 2.53 Wheel Suspension 5x5
API List
This is a list of all API functions currently available[1].
GridTerminalSystem
Currently only following “built-in” variable that user can use: GridTerminalSystem. This is entry point of entire grid terminal system.
Properties
Property | Return Type | Description | get | set |
---|---|---|---|---|
Blocks | List<IMyTerminalBlock> | Returns a list of all blocks on the grid | V | X |
BlockGroups | List<IMyBlockGroup> | Returns a list of all groups in the grid. | V | X |
Methods
Method | Return Type | Description |
---|---|---|
GetBlocksOfType<T>(List<IMyTerminalBlock> blocks, Func<IMyTerminalBlock, bool> collect = null) | void | Puts all found blocks of provided type in the list that are connected to the grid |
SearchBlocksOfName(string name,List<IMyTerminalBlock> blocks, Func<IMyTerminalBlock, bool> collect = null) | void | Puts all found blocks of provided name in the list that are connected to the grid |
GetBlockWithName(string name) | IMyTerminalBlock | Returns a block with provided name |
IMyCubeBlock
IMyCubeBlock is base class for every terminal block.
Properties
Property | Return Type | Description | get | set |
---|---|---|---|---|
IsBeingHacked | boolean | Returns true if block is being hacked | V | X |
IsFunctional | boolean | Returns true if current block is operational | V | X |
IsWorking | boolean | Returns true if current block is powered | V | X |
Position | VRageMath.Vector3I | Returns current position | V | X |
IMyTerminalBlock
MyTerminalBlock is base class for every terminal block.
Properties
Property | Return Type | Description | get | set |
---|---|---|---|---|
CustomName | String | Returns name of the block | V | X |
CustomNameWithFaction | String | ... | V | X |
DetailedInfo | String | ... | V | X |
ShowOnHUD | boolean | Whether block shows up on hud | V | X |
Methods
Method | Return Type | Description |
---|---|---|
HasLocalPlayerAccess() | boolean | ... |
HasPlayerAccess(long playerId) | boolean | ... |
RequestShowOnHUD(bool enable) | void | ... |
SetCustomName(string text) | void | Set the name of the block |
SetCustomName(StringBuilder text) | void | Set the name of the block |
GetActions(List<ITerminalAction> resultList, Func<ITerminalAction, bool> collect = null) | void | Populates list with available actions |
SearchActionsOfName(string name,List<ITerminalAction> resultList, Func<ITerminalAction, bool> collect = null) | void | Populates list with available actions matching the name (Case Insensitive) |
GetActionWithName(string name) | ITerminalAction | Returns action with specified name (Case Sensitive) |
ITerminalAction
ITerminal action is representation of concrete action that can be triggered.
Properties
Property | Return Type | Description | get | set |
---|---|---|---|---|
Id | String | Returns id of the action | V | X |
Name | StringBuilder | Returns the name of the action | V | X |
Methods
Method | Return Type | Description |
---|---|---|
Apply(IMyCubeBlock block) | void | Apply the action on a block |
IMyFunctionalBlock
IMyFunctionalBlock is base class for every block that can be turned on or off, it’s derived from IMyTerminal block e.g. every Functional block is Terminal block but not all terminal blocks can be turned on or off.
Properties
Property | Return Type | Description | get | set |
---|---|---|---|---|
Enabled | boolean | Returns true if the block is turned on | V | X |
Action List
All terminal blocks have the following properties: Interface name: this name is the name of the block in code, it can differ from the name as displayed in the building screen. E.g. Antenna interface name is IMyRadioAntenna - you need to use this interface if you want to get all antennas.
Parent: this is parent of the block (all blocks have IMyTerminalBlock as parent), this can be used for getting type of blocks instead of concrete block type. E.g. if you want to get all lights in grid you will use IMyLightingBlock, if you want only interior light you can use IMyInteriorLight.
Field: this is read only field available for block e.g. for IMyBeacon you can get Radius property. Based on this property you can increase/decrease radius of beacon.
Actions: these are all available actions for block with their names in game, so if you want to increase broadcast radius for antenna, you need to execute DecreaseRadius action for block.
AntennaInterface name: IMyRadioAntenna Actions
OnOff -> Toggle block On/Off |
Arc FurnaceInterface name: IMyRefinery Actions
OnOff -> Toggle block On/Off |
Artificial MassInterface name: IMyVirtualMass Actions
OnOff -> Toggle block On/Off |
AssemblerInterface name: IMyAssembler Actions
OnOff -> Toggle block On/Off |
BatteryInterface name: IMyBatteryBlock Actions
OnOff -> Toggle block On/Off |
BeaconInterface name: IMyBeacon Actions
OnOff -> Toggle block On/Off |
Button PanelInterface name: IMyButtonPanel Actions AnyoneCanUse -> Anyone Can Use On/Off |
CameraInterface name: IMyCameraBlock Actions
OnOff -> Toggle block On/Off |
CockpitInterface name: IMyCockpit Actions
ControlThrusters -> Control thrusters On/Off |
CollectorInterface name: IMyCollector Actions
OnOff -> Toggle block On/Off |
ConnectorInterface name: IMyShipConnector Actions
OnOff -> Toggle block On/Off |
Control PanelInterface name: IMyControlPanel |
Control StationInterface name: IMyCockpit Actions
ControlThrusters -> Control thrusters On/Off |
DoorInterface name: IMyDoor Actions
OnOff -> Toggle block On/Off |
DrillInterface name: IMyShipDrill Actions
OnOff -> Toggle block On/Off |
Flight SeatInterface name: IMyCockpit Actions
ControlThrusters -> Control thrusters On/Off |
Gatling TurretInterface name: IMyLargeGatlingTurret Actions
OnOff -> Toggle block On/Off |
Gravity GeneratorInterface name: IMyGravityGenerator Actions
OnOff -> Toggle block On/Off |
GrinderInterface name: IMyShipGrinder Actions
OnOff -> Toggle block On/Off |
GyroscopeInterface name: IMyGyro Actions |
Interior LightInterface name: IMyInteriorLight Actions |
Interior TurretInterface name: IMyLargeInteriorTurret Actions |
Landing GearInterface name: IMyLandingGear Actions |
Small Cargo ContainerInterface name: IMyCargoContainer |
Medium Cargo ContainerInterface name: IMyCargoContainer |
Large Cargo ContainerInterface name: IMyCargoContainer |
Small ReactorInterface name: IMyReactor Actions |
Large ReactorInterface name: IMyReactor Actions |
Small ThrusterInterface name: IMyThrust Actions |
Large ThrusterInterface name: IMyThrust Actions |
Medical RoomInterface name: IMyMedicalRoom Actions |
Merge BlockInterface name: IMyShipMergeBlock Actions |
Missile TurretInterface name: IMyLargeMissileTurret Actions |
Ore DetectorInterace name: IMyOreDetector Actions |
Passenger SeatInterface name: IMyCockpit Actions |
PistonInterface name: IMyPistonBase Actions |
Programmable blockInterface name: IMyProgrammableBlock Actions |
RefineryInterface name: IMyRefinery Actions |
SpotlightInterface name: IMyReflectorLight Actions |
Remote ControlInterface name: IMyRemoteControl Actions |
Rocket LauncherInterface name: IMySmallMissileLauncher Actions |
Reloadable Rocket LauncherInterface name: IMySmallMissileLauncherReload Actions |
RotorInterface name: IMyMotorStator Actions |
SensorInterface name: IMySensorBlock Actions |
Solar PanelInterface name: IMySolarPanel |
Sound BlockInterface name: IMySoundBlock Actions |
Spherical Gravity GeneratorInterface name: IMyGravityGeneratorSphere Actions |
Timer BlockInterface name: IMyTimerBlock Actions |
WarheadInterface name: IMyWarhead Actions |
WelderInterface name: IMyShipWelder Actions |
Wheel Suspension 1x1Interface name: IMyMotorSuspension Actions |
Wheel Suspension 3x3Interface name: IMyMotorSuspension Actions |
Wheel Suspension 5x5Interface name: IMyMotorSuspension Actions |