Difference between revisions of "Programmable Block"

From Space Engineers Wiki
Jump to: navigation, search
(saved draft. Tons more to add)
Line 54: Line 54:
 
}}
 
}}
  
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.
+
== Overview ==
 +
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.
  
 +
== Usage ==
 
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.  
+
*Since [[Update 01.067]] each programmable block has a maximum limit of '''50,000''' characters for any in-game script.  
  
== API List ==
+
== Media ==
  
This is a list of all API functions currently available<ref>http://steamcommunity.com/sharedfiles/filedetails/?id=360966557</ref>.
+
== Tips ==
  
=== GridTerminalSystem ===
+
== Known Issues ==
 +
*'''Foreach not working at 64- bit''': - Problem:
 +
Currently using of foreach loop inside script will cause “bad program exception” at some configurations and prevent script from running. We are working of fixing this issue.
 +
Workaround:
 +
All our interfaces used in in-game scripting are using lists as collections. Please use For loop for iteration across these lists
  
Currently only following “built-in” variable that user can use: GridTerminalSystem. This is entry point of entire grid terminal system.
+
*'''Lambda functions not working''' - Problem:
 +
Currently lambda functions are not supported, if you use them in script, exception will be thrown and script will not run.
 +
Workaround:
 +
Please use method instead of lambda function if possible.
  
==== Properties ====
+
*'''User defined variables are not saved''' - Problem:
 +
None of the user defined variables inside script are saved, therefore after loading game they are reset to their default values.
 +
Workaround:
 +
We added string variable called "Storage" that will be loaded and saved when the block is loaded and saved.
  
{| class="wikitable"
 
! 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 ====
+
== See Also ==
 +
* [[Programming Guide]]
  
{| class="wikitable"
+
== Programming ==
! Method
+
* [[Programming_Guide/Action_List#Programmable_block|Action List - Programmable block]]
! 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 ===
+
== Update History ==
 
 
IMyCubeBlock is base class for every terminal block.
 
 
 
==== Properties ====
 
 
 
{| class="wikitable"
 
! 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 ====
 
 
 
{| class="wikitable"
 
! 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 ====
 
 
 
{| class="wikitable"
 
! 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 ====
 
 
 
{| class="wikitable"
 
! 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 ====
 
 
 
{| class="wikitable"
 
! 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 ====
 
 
 
{| class="wikitable"
 
! 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.
 
 
 
{|
 
|
 
=== Antenna ===
 
 
 
'''Interface name:''' IMyRadioAntenna<br />
 
'''Parent:''' IMyFunctionalBlock<br />
 
'''Fields:''' float Radius
 
 
 
'''Actions'''
 
OnOff -> Toggle block On/Off<br />
 
OnOff_On -> Toggle block On<br />
 
OnOff_Off -> Toggle block Off<br />
 
IncreaseRadius -> Increase Broadcast radius<br />
 
DecreaseRadius -> Decrease Broadcast radius
 
|
 
=== Arc Furnace ===
 
 
 
'''Interface name:''' IMyRefinery<br />
 
'''Parent:''' IMyProductionBlock<br />
 
'''Parent:''' IMyFunctionalBlock<br />
 
'''Fields:'''  bool UseConveyorSystem
 
 
 
'''Actions'''
 
OnOff -> Toggle block On/Off<br />
 
OnOff_On -> Toggle block On<br />
 
OnOff_Off -> Toggle block Off<br />
 
UseConveyor -> Use Conveyor System On/Off
 
|
 
=== Artificial Mass ===
 
 
 
'''Interface name:''' IMyVirtualMass<br />
 
'''Parent:''' IMyFunctionalBlock<br />
 
'''Fields:'''  None
 
 
 
'''Actions'''
 
OnOff -> Toggle block On/Off<br />
 
OnOff_On -> Toggle block On<br />
 
OnOff_Off -> Toggle block Off
 
|-
 
|
 
=== Assembler ===
 
 
 
'''Interface name:''' IMyAssembler<br />
 
'''Parent:''' IMyProductionBlock<br />
 
'''Parent:''' IMyFunctionalBlock<br />
 
'''Fields:'''  bool UseConveyorSystem
 
 
 
'''Actions'''
 
OnOff -> Toggle block On/Off<br />
 
OnOff_On -> Toggle block On<br />
 
OnOff_Off -> Toggle block Off<br />
 
UseConveyor -> Use Conveyor System On/Off
 
|
 
=== Battery ===
 
 
 
'''Interface name:''' IMyBatteryBlock<br />
 
'''Parent:''' IMyFunctionalBlock<br />
 
'''Fields:'''  bool HasCapacityRemaining
 
 
 
'''Actions'''
 
OnOff -> Toggle block On/Off<br />
 
OnOff_On -> Toggle block On<br />
 
OnOff_Off -> Toggle block Off<br />
 
Recharge -> Recharge On/Off
 
|
 
=== Beacon ===
 
 
 
'''Interface name:''' IMyBeacon<br />
 
'''Parent:''' IMyFunctionalBlock<br />
 
'''Fields:'''  float Radius
 
 
 
'''Actions'''
 
OnOff -> Toggle block On/Off<br />
 
OnOff_On -> Toggle block On<br />
 
OnOff_Off -> Toggle block Off<br />
 
IncreaseRadius -> Increase Broadcast radius<br />
 
DecreaseRadius -> Decrease Broadcast radius
 
|-
 
|
 
=== Button Panel ===
 
 
 
'''Interface name:''' IMyButtonPanel<br />
 
'''Fields:'''  bool AnyoneCanUse
 
 
 
'''Actions'''
 
AnyoneCanUse -> Anyone Can Use On/Off
 
|
 
=== Camera ===
 
'''Interface name:''' IMyCameraBlock<br />
 
'''Parent:''' IMyFunctionalBlock<br />
 
'''Fields:'''  None
 
 
 
'''Actions'''
 
OnOff -> Toggle block On/Off<br />
 
OnOff_On -> Toggle block On<br />
 
OnOff_Off -> Toggle block Off<br />
 
View -> View
 
|
 
=== Cockpit ===
 
 
 
'''Interface name:''' IMyCockpit<br />
 
'''Parent:''' IMyShipController<br />
 
'''Fields:''' <br />
 
bool ControlWheels<br />
 
bool ControlThrusters<br />
 
bool HandBrake <br />
 
bool DampenersOverride
 
 
 
'''Actions'''
 
ControlThrusters -> Control thrusters On/Off<br />
 
ControlWheels -> Control wheels On/Off<br />
 
HandBrake -> Handbrake On/Off<br />
 
DampenersOverride -> Inertia dampeners On/Off
 
|-
 
|
 
=== Collector ===
 
 
 
'''Interface name:''' IMyCollector<br />
 
'''Parent:''' IMyFunctionalBlock<br />
 
'''Fields:'''  bool UseConveyorSystem
 
 
 
'''Actions'''
 
OnOff -> Toggle block On/Off<br />
 
OnOff_On -> Toggle block On<br />
 
OnOff_Off -> Toggle block Off<br />
 
UseConveyor -> Use Conveyor System On/Off
 
|
 
=== Connector ===
 
 
 
'''Interface name:''' IMyShipConnector<br />
 
'''Parent:''' IMyFunctionalBlock<br />
 
'''Fields:''' <br />
 
bool ThrowOut <br />
 
bool CollectAll <br />
 
bool IsLocked
 
 
 
'''Actions'''
 
OnOff -> Toggle block On/Off<br />
 
OnOff_On -> Toggle block On<br />
 
OnOff_Off -> Toggle block Off<br />
 
ThrowOut -> Throw Out On/Off<br />
 
CollectAll -> Collect All On/Off<br />
 
SwitchLock -> Switch lock
 
|
 
=== Control Panel ===
 
 
 
'''Interface name:''' IMyControlPanel<br />
 
'''Fields:'''  None<br />
 
'''Actions:''' None
 
|-
 
|
 
=== Control Station ===
 
 
 
'''Interface name:''' IMyCockpit<br />
 
'''Parent:''' IMyShipController<br />
 
'''Fields:''' <br />
 
bool ControlWheels<br />
 
bool ControlThrusters<br />
 
bool HandBrake <br />
 
bool DampenersOverride
 
 
 
'''Actions'''
 
ControlThrusters -> Control thrusters On/Off<br />
 
ControlWheels -> Control wheels On/Off<br />
 
HandBrake -> Handbrake On/Off<br />
 
DampenersOverride -> Inertia dampeners On/Off
 
|
 
=== Door ===
 
 
 
'''Interface name:''' IMyDoor<br />
 
'''Parent:''' IMyFunctionalBlock<br />
 
'''Fields:'''  bool Open
 
 
 
'''Actions'''
 
OnOff -> Toggle block On/Off<br />
 
OnOff_On -> Toggle block On<br />
 
OnOff_Off -> Toggle block Off<br />
 
Open -> Open/Closed<br />
 
Open_On -> Open<br />
 
Open_Off -> Closed
 
|
 
=== Drill ===
 
 
 
'''Interface name:''' IMyShipDrill<br />
 
'''Parent:''' IMyFunctionalBlock<br />
 
'''Fields:'''  bool UseConveyorSystem
 
 
 
'''Actions'''
 
OnOff -> Toggle block On/Off<br />
 
OnOff_On -> Toggle block On<br />
 
OnOff_Off -> Toggle block Off<br />
 
UseConveyor -> Use Conveyor System On/Off
 
|-
 
|
 
=== Flight Seat ===
 
 
 
'''Interface name:''' IMyCockpit<br />
 
'''Parent:''' IMyShipController<br />
 
'''Fields:''' <br />
 
bool ControlWheels<br />
 
bool ControlThrusters<br />
 
bool HandBrake <br />
 
bool DampenersOverride
 
 
 
'''Actions'''
 
ControlThrusters -> Control thrusters On/Off<br />
 
ControlWheels -> Control wheels On/Off<br />
 
HandBrake -> Handbrake On/Off<br />
 
DampenersOverride -> Inertia dampeners On/Off
 
|
 
=== Gatling Turret ===
 
 
 
'''Interface name:''' IMyLargeGatlingTurret<br />
 
'''Parent:''' IMyLargeConveyorTurretBase<br />
 
'''Parent:''' IMyLargeTurretBase<br />
 
'''Parent:''' IMyFunctionalBlock<br />
 
'''Fields:''' <br />
 
bool UseConveyorSystem <br />
 
bool CanControl<br />
 
float Range
 
 
 
'''Actions'''
 
OnOff -> Toggle block On/Off<br />
 
OnOff_On -> Toggle block On<br />
 
OnOff_Off -> Toggle block Off<br />
 
Control -> Control<br />
 
IncreaseRange -> Increase Radius<br />
 
DecreaseRange -> Decrease Radius<br />
 
UseConveyor -> Use Conveyor System On/Off
 
|
 
=== Gravity Generator ===
 
 
 
'''Interface name:''' IMyGravityGenerator<br />
 
'''Parent:''' IMyGravityGeneratorBase<br />
 
'''Parent:''' IMyFunctionalBlock<br />
 
'''Fields:''' <br />
 
float FieldWidth <br />
 
float FieldHeight <br />
 
float FieldDepth <br />
 
float Gravity
 
 
 
'''Actions'''
 
OnOff -> Toggle block On/Off<br />
 
OnOff_On -> Toggle block On<br />
 
OnOff_Off -> Toggle block Off<br />
 
IncreaseWidth -> Increase Field width<br />
 
DecreaseWidth -> Decrease Field width<br />
 
IncreaseHeight -> Increase Field height<br />
 
DecreaseHeight -> Decrease Field height<br />
 
IncreaseDepth -> Increase Field depth<br />
 
DecreaseDepth -> Decrease Field depth<br />
 
IncreaseGravity -> Increase Acceleration<br />
 
DecreaseGravity -> Decrease Acceleration
 
|-
 
|
 
=== Grinder ===
 
 
 
'''Interface name:''' IMyShipGrinder<br />
 
'''Parent:''' IMyShipToolBase<br />
 
'''Parent:''' IMyFunctionalBlock<br />
 
'''Fields:'''  None
 
 
 
'''Actions'''
 
OnOff -> Toggle block On/Off<br />
 
OnOff_On -> Toggle block On<br />
 
OnOff_Off -> Toggle block Off<br />
 
UseConveyor -> Use Conveyor System On/Off
 
|
 
=== Gyroscope ===
 
 
 
'''Interface name:''' IMyGyro<br />
 
'''Parent:''' IMyFunctionalBlock<br />
 
'''Fields:''' <br />
 
float GyroPower <br />
 
bool GyroOverride <br />
 
float Yaw <br />
 
float Pitch <br />
 
float Roll
 
 
 
'''Actions'''<br />
 
OnOff -> Toggle block On/Off<br />
 
OnOff_On -> Toggle block On<br />
 
OnOff_Off -> Toggle block Off<br />
 
IncreasePower -> Increase Power<br />
 
DecreasePower -> Decrease Power<br />
 
Override -> Override controls On/Off<br />
 
IncreaseYaw -> Increase Yaw override<br />
 
DecreaseYaw -> Decrease Yaw override<br />
 
IncreasePitch -> Increase Pitch override<br />
 
DecreasePitch -> Decrease Pitch override<br />
 
IncreaseRoll -> Increase Roll override<br />
 
DecreaseRoll -> Decrease Roll override
 
|
 
=== Interior Light ===
 
 
 
'''Interface name:''' IMyInteriorLight<br />
 
'''Parent:''' IMyLightingBlock<br />
 
'''Parent:''' IMyFunctionalBlock<br />
 
'''Fields:'''<br />
 
float Radius<br />
 
float Intensity<br />
 
float BlinkIntervalSeconds<br />
 
float BlinkLenght<br />
 
float BlinkOffset
 
 
 
'''Actions'''<br />
 
OnOff -> Toggle block On/Off<br />
 
OnOff_On -> Toggle block On<br />
 
OnOff_Off -> Toggle block Off<br />
 
IncreaseRadius -> Increase Radius<br />
 
DecreaseRadius -> Decrease Radius<br />
 
IncreaseBlink Interval -> Increase Blink Interval<br />
 
DecreaseBlink Interval -> Decrease Blink Interval<br />
 
IncreaseBlink Lenght -> Increase Blink Length<br />
 
DecreaseBlink Lenght -> Decrease Blink Length<br />
 
IncreaseBlink Offset -> Increase Blink Offset<br />
 
DecreaseBlink Offset -> Decrease Blink Offset
 
|-
 
|
 
=== Interior Turret ===
 
 
 
'''Interface name:''' IMyLargeInteriorTurret<br />
 
'''Parent:''' IMyLargeTurretBase<br />
 
'''Parent:''' IMyFunctionalBlock<br />
 
'''Fields:'''<br />
 
bool CanControl<br />
 
float Range
 
 
 
'''Actions'''<br />
 
OnOff -> Toggle block On/Off<br />
 
OnOff_On -> Toggle block On<br />
 
OnOff_Off -> Toggle block Off<br />
 
Control -> Control<br />
 
IncreaseRange -> Increase Radius<br />
 
DecreaseRange -> Decrease Radius
 
|
 
=== Landing Gear ===
 
 
 
'''Interface name:''' IMyLandingGear<br />
 
'''Parent:''' IMyFunctionalBlock<br />
 
'''Fields:'''<br />
 
float BreakForce
 
 
 
'''Actions'''<br />
 
OnOff -> Toggle block On/Off<br />
 
OnOff_On -> Toggle block On<br />
 
OnOff_Off -> Toggle block Off<br />
 
Lock -> Lock<br />
 
Unlock -> Unlock<br />
 
SwitchLock -> Switch lock<br />
 
Autolock -> Autolock On/Off<br />
 
IncreaseBreakForce -> Increase Break Force<br />
 
DecreaseBreakForce -> Decrease Break Force
 
|
 
=== Small Cargo Container ===
 
 
 
'''Interface name:''' IMyCargoContainer<br />
 
'''Fields:''' None<br />
 
'''Actions:''' None
 
|-
 
|
 
=== Medium Cargo Container ===
 
 
 
'''Interface name:''' IMyCargoContainer<br />
 
'''Fields:''' None<br />
 
'''Actions:''' None
 
|
 
=== Large Cargo Container ===
 
 
 
'''Interface name:''' IMyCargoContainer<br />
 
'''Fields:''' None<br />
 
'''Actions:''' None
 
|
 
=== Small Reactor ===
 
 
 
'''Interface name:''' IMyReactor<br />
 
'''Parent:''' IMyFunctionalBlock<br />
 
'''Fields:'''<br />
 
bool UseConveyorSystem
 
 
 
'''Actions'''<br />
 
OnOff -> Toggle block On/Off<br />
 
OnOff_On -> Toggle block On<br />
 
OnOff_Off -> Toggle block Off<br />
 
UseConveyor -> Use Conveyor System On/Off
 
|-
 
|
 
=== Large Reactor ===
 
 
 
'''Interface name:''' IMyReactor<br />
 
'''Parent:''' IMyFunctionalBlock<br />
 
'''Fields:''' bool UseConveyorSystem
 
 
 
'''Actions'''<br />
 
OnOff -> Toggle block On/Off<br />
 
OnOff_On -> Toggle block On<br />
 
OnOff_Off -> Toggle block Off<br />
 
UseConveyor -> Use Conveyor System On/Off
 
|
 
=== Small Thruster ===
 
 
 
'''Interface name:''' IMyThrust<br />
 
'''Parent:''' IMyFunctionalBlock<br />
 
'''Fields:''' float ThrustOverride
 
 
 
'''Actions'''<br />
 
OnOff -> Toggle block On/Off<br />
 
OnOff_On -> Toggle block On<br />
 
OnOff_Off -> Toggle block Off<br />
 
IncreaseOverride -> Increase Thrust override<br />
 
DecreaseOverride -> Decrease Thrust override
 
|
 
=== Large Thruster ===
 
 
 
'''Interface name:''' IMyThrust<br />
 
'''Parent:''' IMyFunctionalBlock<br />
 
'''Fields:''' float ThrustOverride
 
 
 
'''Actions'''<br />
 
OnOff -> Toggle block On/Off<br />
 
OnOff_On -> Toggle block On<br />
 
OnOff_Off -> Toggle block Off<br />
 
IncreaseOverride -> Increase Thrust override<br />
 
DecreaseOverride -> Decrease Thrust override
 
|-
 
|
 
=== Medical Room ===
 
 
 
'''Interface name:''' IMyMedicalRoom<br />
 
'''Parent:''' IMyFunctionalBlock<br />
 
'''Fields:''' None
 
 
 
'''Actions'''<br />
 
OnOff -> Toggle block On/Off<br />
 
OnOff_On -> Toggle block On<br />
 
OnOff_Off -> Toggle block Off
 
|
 
=== Merge Block ===
 
 
 
'''Interface name:''' IMyShipMergeBlock<br />
 
'''Parent:''' IMyFunctionalBlock<br />
 
'''Fields:''' None
 
 
 
'''Actions'''<br />
 
OnOff -> Toggle block On/Off<br />
 
OnOff_On -> Toggle block On<br />
 
OnOff_Off -> Toggle block Off
 
|
 
=== Missile Turret ===
 
 
 
'''Interface name:''' IMyLargeMissileTurret<br />
 
'''Parent:''' IMyLargeConveyorTurretBase<br />
 
'''Parent:''' IMyLargeTurretBase<br />
 
'''Parent:''' IMyFunctionalBlock<br />
 
'''Fields:'''<br />
 
bool UseConveyorSystem <br />
 
bool CanControl<br />
 
float Range
 
 
 
'''Actions'''<br />
 
OnOff -> Toggle block On/Off<br />
 
OnOff_On -> Toggle block On<br />
 
OnOff_Off -> Toggle block Off<br />
 
Control -> Control<br />
 
IncreaseRange -> Increase Radius<br />
 
DecreaseRange -> Decrease Radius<br />
 
UseConveyor -> Use Conveyor System On/Of
 
|-
 
|
 
=== Ore Detector ===
 
 
 
Interace name: IMyOreDetector<br />
 
'''Parent:''' IMyFunctionalBlock<br />
 
'''Fields:'''<br />
 
float Range <br />
 
bool BroadcastUsingAntennas
 
 
 
'''Actions'''<br />
 
OnOff -> Toggle block On/Off<br />
 
OnOff_On -> Toggle block On<br />
 
OnOff_Off -> Toggle block Off
 
|
 
=== Passenger Seat ===
 
 
 
'''Interface name:''' IMyCockpit<br />
 
'''Parent:''' IMyShipController<br />
 
'''Fields:'''<br />
 
bool ControlWheels<br />
 
bool ControlThrusters<br />
 
bool HandBrake <br />
 
bool DampenersOverride
 
 
 
'''Actions'''<br />
 
ControlThrusters -> Control thrusters On/Off<br />
 
ControlWheels -> Control wheels On/Off<br />
 
HandBrake -> Handbrake On/Off<br />
 
DampenersOverride -> Inertia dampeners On/Off
 
|
 
=== Piston ===
 
 
 
'''Interface name:''' IMyPistonBase<br />
 
'''Parent:''' IMyFunctionalBlock<br />
 
'''Fields:'''<br />
 
float Velocity <br />
 
float MinLimit <br />
 
float MaxLimit
 
 
 
'''Actions'''<br />
 
OnOff -> Toggle block On/Off<br />
 
OnOff_On -> Toggle block On<br />
 
OnOff_Off -> Toggle block Off<br />
 
Reverse -> Reverse<br />
 
IncreaseVelocity -> Increase Velocity<br />
 
DecreaseVelocity -> Decrease Velocity<br />
 
ResetVelocity -> Reset Velocity<br />
 
IncreaseUpperLimit -> Increase Maximal distance<br />
 
DecreaseUpperLimit -> Decrease Maximal distance<br />
 
IncreaseLowerLimit -> Increase Minimal distance<br />
 
DecreaseLowerLimit -> Decrease Minimal distance
 
|-
 
|
 
=== Programmable block ===
 
 
 
'''Interface name:''' IMyProgrammableBlock<br />
 
'''Parent:''' IMyFunctionalBlock<br />
 
'''Fields:''' bool IsRunning
 
 
 
'''Actions'''<br />
 
OnOff -> Toggle block On/Off<br />
 
OnOff_On -> Toggle block On<br />
 
OnOff_Off -> Toggle block Off<br />
 
Run -> Run
 
|
 
=== Refinery ===
 
 
 
'''Interface name:''' IMyRefinery<br />
 
'''Parent:''' IMyFunctionalBlock<br />
 
'''Parent:''' IMyProductionBlock<br />
 
'''Fields:''' bool UseConveyorSystem
 
 
 
'''Actions'''<br />
 
OnOff -> Toggle block On/Off<br />
 
OnOff_On -> Toggle block On<br />
 
OnOff_Off -> Toggle block Off<br />
 
UseConveyor -> Use Conveyor System On/Off
 
|
 
=== Spotlight ===
 
 
 
'''Interface name:''' IMyReflectorLight<br />
 
'''Parent:''' IMyLightingBlock<br />
 
'''Parent:''' IMyFunctionalBlock<br />
 
'''Fields:'''<br />
 
float Radius<br />
 
float Intensity<br />
 
float BlinkIntervalSeconds<br />
 
float BlinkLenght<br />
 
float BlinkOffset
 
 
 
'''Actions'''<br />
 
OnOff -> Toggle block On/Off<br />
 
OnOff_On -> Toggle block On<br />
 
OnOff_Off -> Toggle block Off<br />
 
IncreaseRadius -> Increase Radius<br />
 
DecreaseRadius -> Decrease Radius<br />
 
IncreaseBlink Interval -> Increase Blink Interval<br />
 
DecreaseBlink Interval -> Decrease Blink Interval<br />
 
IncreaseBlink Lenght -> Increase Blink Length<br />
 
DecreaseBlink Lenght -> Decrease Blink Length<br />
 
IncreaseBlink Offset -> Increase Blink Offset<br />
 
DecreaseBlink Offset -> Decrease Blink Offset
 
|-
 
|
 
=== Remote Control ===
 
 
 
'''Interface name:''' IMyRemoteControl<br />
 
'''Parent:''' IMyShipController<br />
 
'''Fields:'''<br />
 
bool ShowInTerminal<br />
 
bool ShowInToolbarConfig<br />
 
bool ShowOnHUD<br />
 
bool ControlThrusters<br />
 
bool ControlWheels<br />
 
bool HandBrake<br />
 
bool DampenersOverride<br />
 
bool MainCockpit<br />
 
bool HorizonIndicator<br />
 
bool AutoPilot<br />
 
bool CollisionAvoidance<br />
 
bool DockingMode<br />
 
 
 
 
 
'''Actions'''<br />
 
ControlThrusters -> Control thrusters On/Off<br />
 
ControlWheels -> Control wheels On/Off<br />
 
HandBrake -> Handbrake On/Off<br />
 
DampenersOverride -> Inertia dampeners On/Off<br />
 
Control -> Control<br />
 
MainCockpit -> Main cockpit On/Off<br />
 
HorizonIndicator -> Show horizon and altitude On/Off<br />
 
AutoPilot -> Autopilot On/Off<br />
 
AutoPilot_On -> Autopilot On<br />
 
AutoPilot_Off -> Autopilot Off<br />
 
CollisionAvoidance -> Collision avoidance On/Off<br />
 
CollisionAvoidance_On -> Collision avoidance On<br />
 
CollisionAvoidance_Off -> Collision avoidance Off<br />
 
DockingMode -> Precision Mode On/Off<br />
 
DockingMode_On -> Precision Mode On<br />
 
DockingMode_Off -> Precision Mode Off<br />
 
Forward -> Forward<br />
 
Backward -> Backward<br />
 
Left -> Left<br />
 
Right -> Right<br />
 
Up -> Up<br />
 
Down -> Down
 
|
 
=== Rocket Launcher ===
 
 
 
'''Interface name:''' IMySmallMissileLauncher<br />
 
'''Parent:''' IMyFunctionalBlock<br />
 
'''Fields:''' bool UseConveyorSystem
 
 
 
'''Actions'''<br />
 
OnOff -> Toggle block On/Off<br />
 
OnOff_On -> Toggle block On<br />
 
OnOff_Off -> Toggle block Off<br />
 
UseConveyor -> Use Conveyor System On/Off
 
|
 
=== Reloadable Rocket Launcher ===
 
 
 
'''Interface name:''' IMySmallMissileLauncherReload<br />
 
'''Parent:''' IMyFunctionalBlock<br />
 
'''Fields:''' bool UseConveyorSystem
 
 
 
'''Actions'''<br />
 
OnOff -> Toggle block On/Off<br />
 
OnOff_On -> Toggle block On<br />
 
OnOff_Off -> Toggle block Off<br />
 
UseConveyor -> Use Conveyor System On/Off
 
|-
 
|
 
=== Rotor ===
 
 
 
'''Interface name:''' IMyMotorStator<br />
 
'''Parent:''' IMyMotorBase<br />
 
'''Parent:''' IMyFunctionalBlock<br />
 
'''Fields:'''<br />
 
bool IsAttached <br />
 
float Torque<br />
 
float BrakingTorque <br />
 
float Velocity <br />
 
float LowerLimit <br />
 
float UpperLimit <br />
 
float Displacement
 
 
 
'''Actions'''<br />
 
OnOff -> Toggle block On/Off<br />
 
OnOff_On -> Toggle block On<br />
 
OnOff_Off -> Toggle block Off<br />
 
Reverse -> Reverse<br />
 
Detach -> Detach<br />
 
Attach -> Attach<br />
 
IncreaseTorque -> Increase Torque<br />
 
DecreaseTorque -> Decrease Torque<br />
 
IncreaseBrakingTorque -> Increase Braking tor.<br />
 
DecreaseBrakingTorque -> Decrease Braking tor.<br />
 
IncreaseVelocity -> Increase Velocity<br />
 
DecreaseVelocity -> Decrease Velocity<br />
 
ResetVelocity -> Reset Velocity<br />
 
IncreaseLowerLimit -> Increase Lower limit<br />
 
DecreaseLowerLimit -> Decrease Lower limit<br />
 
IncreaseUpperLimit -> Increase Upper limit<br />
 
DecreaseUpperLimit -> Decrease Upper limit<br />
 
IncreaseDisplacement -> Increase Rotor displacement<br />
 
DecreaseDisplacement -> Decrease Rotor displacement
 
|
 
=== Sensor ===
 
 
 
'''Interface name:''' IMySensorBlock<br />
 
'''Parent:''' IMyFunctionalBlock<br />
 
'''Fields:'''<br />
 
float LeftExtend <br />
 
float RightExtend <br />
 
float TopExtend <br />
 
float BottomExtend <br />
 
float FrontExtend <br />
 
float BackExtend <br />
 
bool DetectPlayers <br />
 
bool DetectFloatingObjects <br />
 
bool DetectSmallShips <br />
 
bool DetectLargeShips <br />
 
bool DetectStations <br />
 
bool DetectAsteroids
 
 
 
'''Actions'''<br />
 
OnOff -> Toggle block On/Off<br />
 
OnOff_On -> Toggle block On<br />
 
OnOff_Off -> Toggle block Off<br />
 
IncreaseLeft -> Increase Left extent<br />
 
DecreaseLeft -> Decrease Left extent<br />
 
IncreaseRight -> Increase Right extent<br />
 
DecreaseRight -> Decrease Right extent<br />
 
IncreaseBottom -> Increase Bottom extent<br />
 
DecreaseBottom -> Decrease Bottom extent<br />
 
IncreaseTop -> Increase Top extent<br />
 
DecreaseTop -> Decrease Top extent<br />
 
IncreaseBack -> Increase Back extent<br />
 
DecreaseBack -> Decrease Back extent<br />
 
IncreaseFront -> Increase Front extent<br />
 
DecreaseFront -> Decrease Front extent<br />
 
Detect Players -> Detect players On/Off<br />
 
Detect Floating Objects -> Detect floating objects On/Off<br />
 
Detect Small Ships -> Detect small ships On/Off<br />
 
Detect Large Ships -> Detect large ships On/Off<br />
 
Detect Stations -> Detect stations On/Off<br />
 
Detect Asteroids -> Detect Asteroids On/Off
 
|
 
=== Solar Panel ===
 
 
 
'''Interface name:''' IMySolarPanel<br />
 
'''Fields:'''None<br />
 
'''Actions:''' None
 
|-
 
|
 
=== Sound Block ===
 
 
 
'''Interface name:''' IMySoundBlock<br />
 
'''Parent:''' IMyFunctionalBlock<br />
 
'''Fields:'''<br />
 
float Volume <br />
 
float Range <br />
 
bool IsSoundSelected<br />
 
float LoopPeriod
 
 
 
'''Actions'''<br />
 
OnOff -> Toggle block On/Off<br />
 
OnOff_On -> Toggle block On<br />
 
OnOff_Off -> Toggle block Off<br />
 
IncreaseVolumeSlider -> Increase Volume<br />
 
DecreaseVolumeSlider -> Decrease Volume<br />
 
IncreaseRangeSlider -> Increase Range<br />
 
DecreaseRangeSlider -> Decrease Range<br />
 
PlaySound -> Play<br />
 
StopSound -> Stop<br />
 
IncreaseLoopableSlider -> Increase Loop time<br />
 
DecreaseLoopableSlider -> Decrease Loop time
 
|
 
=== Spherical Gravity Generator ===
 
 
 
'''Interface name:''' IMyGravityGeneratorSphere<br />
 
'''Parent:''' IMyGravityGeneratorBase<br />
 
'''Parent:''' IMyFunctionalBlock<br />
 
'''Fields:'''<br />
 
float Radius <br />
 
float Gravity
 
 
 
'''Actions'''<br />
 
OnOff -> Toggle block On/Off<br />
 
OnOff_On -> Toggle block On<br />
 
OnOff_Off -> Toggle block Off<br />
 
IncreaseRadius -> Increase Radius<br />
 
DecreaseRadius -> Decrease Radius<br />
 
IncreaseGravity -> Increase Acceleration<br />
 
DecreaseGravity -> Decrease Acceleration
 
|
 
=== Timer Block ===
 
 
 
'''Interface name:''' IMyTimerBlock<br />
 
'''Parent:''' IMyFunctionalBlock<br />
 
'''Fields:'''<br />
 
bool IsCountingDown <br />
 
float TriggerDelay
 
 
 
'''Actions'''<br />
 
OnOff -> Toggle block On/Off<br />
 
OnOff_On -> Toggle block On<br />
 
OnOff_Off -> Toggle block Off<br />
 
IncreaseTriggerDelay -> Increase Delay<br />
 
DecreaseTriggerDelay -> Decrease Delay<br />
 
TriggerNow -> Trigger now<br />
 
Start -> Start<br />
 
Stop -> Stop
 
|-
 
|
 
=== Warhead ===
 
 
 
'''Interface name:''' IMyWarhead<br />
 
'''Fields:'''<br />
 
bool IsCountingDown <br />
 
float DetonationTime
 
 
 
'''Actions'''<br />
 
IncreaseDetonationTime -> Increase Detonation time<br />
 
DecreaseDetonationTime -> Decrease Detonation time<br />
 
StartCountdown -> Start countdown<br />
 
StopCountdown -> Stop countdown<br />
 
Safety -> Safety On/Off<br />
 
Detonate -> Detonate
 
|
 
=== Welder ===
 
 
 
'''Interface name:''' IMyShipWelder<br />
 
'''Parent:''' IMyShipToolBase<br />
 
'''Parent:''' IMyFunctionalBlock
 
 
 
'''Actions'''<br />
 
OnOff -> Toggle block On/Off<br />
 
OnOff_On -> Toggle block On<br />
 
OnOff_Off -> Toggle block Off<br />
 
UseConveyor -> Use Conveyor System On/Off
 
|
 
=== Wheel Suspension 1x1 ===
 
 
 
'''Interface name:''' IMyMotorSuspension<br />
 
'''Parent:''' IMyMotorBase<br />
 
'''Parent:''' IMyFunctionalBlock<br />
 
'''Fields:'''<br />
 
bool Steering <br />
 
bool Propulsion <br />
 
float Damping <br />
 
float Strength <br />
 
float Friction <br />
 
float Power
 
 
 
'''Actions'''<br />
 
OnOff -> Toggle block On/Off<br />
 
OnOff_On -> Toggle block On<br />
 
OnOff_Off -> Toggle block Off<br />
 
Steering -> Steering On/Off<br />
 
Propulsion -> Propulsion On/Off<br />
 
IncreaseDamping -> Increase Damping<br />
 
DecreaseDamping -> Decrease Damping<br />
 
IncreaseStrength -> Increase Strength<br />
 
DecreaseStrength -> Decrease Strength<br />
 
IncreaseFriction -> Increase Friction<br />
 
DecreaseFriction -> Decrease Friction<br />
 
IncreasePower -> Increase Power<br />
 
DecreasePower -> Decrease Power
 
|-
 
|
 
=== Wheel Suspension 3x3 ===
 
 
 
'''Interface name:''' IMyMotorSuspension<br />
 
'''Parent:''' IMyMotorBase<br />
 
'''Parent:''' IMyFunctionalBlock<br />
 
'''Fields:'''<br />
 
bool Steering <br />
 
bool Propulsion <br />
 
float Damping <br />
 
float Strength <br />
 
float Friction <br />
 
float Power
 
 
 
'''Actions'''<br />
 
OnOff -> Toggle block On/Off<br />
 
OnOff_On -> Toggle block On<br />
 
OnOff_Off -> Toggle block Off<br />
 
Steering -> Steering On/Off<br />
 
Propulsion -> Propulsion On/Off<br />
 
IncreaseDamping -> Increase Damping<br />
 
DecreaseDamping -> Decrease Damping<br />
 
IncreaseStrength -> Increase Strength<br />
 
DecreaseStrength -> Decrease Strength<br />
 
IncreaseFriction -> Increase Friction<br />
 
DecreaseFriction -> Decrease Friction<br />
 
IncreasePower -> Increase Power<br />
 
DecreasePower -> Decrease Power
 
|
 
=== Wheel Suspension 5x5 ===
 
 
 
'''Interface name:''' IMyMotorSuspension<br />
 
'''Parent:''' IMyMotorBase<br />
 
'''Parent:''' IMyFunctionalBlock<br />
 
'''Fields:'''<br />
 
bool Steering <br />
 
bool Propulsion <br />
 
float Damping <br />
 
float Strength <br />
 
float Friction <br />
 
float Power
 
 
 
'''Actions'''<br />
 
OnOff -> Toggle block On/Off<br />
 
OnOff_On -> Toggle block On<br />
 
OnOff_Off -> Toggle block Off<br />
 
Steering -> Steering On/Off<br />
 
Propulsion -> Propulsion On/Off<br />
 
IncreaseDamping -> Increase Damping<br />
 
DecreaseDamping -> Decrease Damping<br />
 
IncreaseStrength -> Increase Strength<br />
 
DecreaseStrength -> Decrease Strength<br />
 
IncreaseFriction -> Increase Friction<br />
 
DecreaseFriction -> Decrease Friction<br />
 
IncreasePower -> Increase Power<br />
 
DecreasePower -> Decrease Power
 
|
 
|}
 
<references />
 

Revision as of 12:34, 29 November 2015


Programmable Block Icon.png
Large Ship Icon.png
Large Ship / Station
Programmable Block
 
Components
Required

 

 
 
1
 
 
Mass (kg):
0
 
Integrity:
0
 
Build time (seconds):
20
 
Active power consumption (MW):
0.0005
 
Dimensions (W x H x D):
1 x 1 x 1
Programmable Block Icon.png
Small Ship Icon.png
Small Ship
Programmable Block
 
Components
Required

 

 
 
1
 
 
Mass (kg):
0
 
Integrity:
0
 
Build time (seconds):
20
 
Active power consumption (MW):
0.0005
 
Dimensions (W x H x D):
1 x 1 x 1

Overview

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.

Usage

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.

Media

Tips

Known Issues

  • Foreach not working at 64- bit: - Problem:

Currently using of foreach loop inside script will cause “bad program exception” at some configurations and prevent script from running. We are working of fixing this issue. Workaround: All our interfaces used in in-game scripting are using lists as collections. Please use For loop for iteration across these lists

  • Lambda functions not working - Problem:

Currently lambda functions are not supported, if you use them in script, exception will be thrown and script will not run. Workaround: Please use method instead of lambda function if possible.

  • User defined variables are not saved - Problem:

None of the user defined variables inside script are saved, therefore after loading game they are reset to their default values. Workaround: We added string variable called "Storage" that will be loaded and saved when the block is loaded and saved.


See Also

Programming

Update History