Space Engineers

Space Engineers

Not enough ratings
Inertia Dampeners if no Pilot
   
Award
Favorite
Favorited
Unfavorite
File Size
Posted
485.000 B
15 Jan, 2017 @ 6:30pm
1 Change Note ( view )

Subscribe to download
Inertia Dampeners if no Pilot

Description
WARNING - MUST READ:

This Script will not trigger if a player is in a Passenger Seat or a Cryo Pod!

HOW TO SETUP:

Step 1: Go into the Programmable block with the "Edit" button and select this script from the "Browse Workshop" button.
Step 2: Press "Remember & Exit" and afterwards press "Recompile" just to be sure.
Step 3: Setup a Timer Block with "Setup Actions" to trigger the Programmable block with to "Run with default argument" and to start itself (the Timer Block) again.
Step 4: Start the Timer Block.

WHAT THIS CODE DOES:

It gets a list of all blocks that may controll the ship/vehicle and checks each block if it is controlled by a Player and if the Inertia Dampeners are on. If all checks on all blocks are false it will turn the Inertia Dampeners on.

public bool isControlled() { List<IMyTerminalBlock> list = new List<IMyTerminalBlock>(); GridTerminalSystem.GetBlocksOfType<IMyShipController>(list); bool control = false; for (int x = 0; x < list.Count; x++) { IMyShipController block = list[x] as IMyShipController; if (block.DampenersOverride || block.IsUnderControl) { return true; } } return control; } public void setDampeners() { List<IMyTerminalBlock> list = new List<IMyTerminalBlock>(); GridTerminalSystem.GetBlocksOfType<IMyShipController>(list); IMyCockpit block = list[0] as IMyCockpit; block.GetActionWithName("DampenersOverride").Apply(block); } void Main() { if (!isControlled()) { setDampeners(); } }