bool FuncTest(IMyShipWelder block) { //Welder //Interface name: IMyShipWelder //Parent: IMyShipToolBase //Parent: IMyFunctionalBlock return(true); }
private void ToggleOffShipWelder() { for (int nIndex = 0; nIndex < m_listShipWelder.Count; nIndex++) { IMyShipWelder shipWelder = m_listShipWelder[nIndex]; shipWelder.ApplyAction("OnOff_Off"); } }
private void Exec_Setup() { _projector = GetBlocksOfTypeWithName <IMyProjector>("_MTB").FirstOrDefault(); _timer = GetBlocksOfTypeWithName <IMyTimerBlock>("_MTB").FirstOrDefault(); _welders = GetBlocksOfTypeWithName <IMyShipWelder>("_MTB"); _cutters = GetBlocksOfTypeWithName <IMyThrust>("_MTB"); _torpDock = GetBlocksOfTypeWithName <IMyShipConnector>("_MTB").FirstOrDefault(); _piston = GetBlocksOfTypeWithName <IMyPistonBase>("_MTB").FirstOrDefault(); EchoText( "==SETUP== \n" + "\n" + "Projector: " + ((_projector != null) ? "Ok ✅" : "Not found") + "\n" + "Timer: " + ((_timer != null) ? "Ok ✅" : "Not found") + "\n" + "Welders: " + ((_welders != null) ? (_welders.Count > 0) ? "Ok ✅" : "Not found" : "Not found") + " (" + _cutters.Count + ")" + "\n" + "Torpedo Dock: " + ((_torpDock != null) ? "Ok ✅" : "Not found") + "\n" + "Piston: " + ((_piston != null) ? "Ok ✅" : "Not found") + "\n" + "Cutters: " + ((_cutters != null) ? (_cutters.Count > 0) ? "Ok ✅" : "Not found" : "Not found") + " (" + _cutters.Count + ")" ); if (_projector == null || _timer == null || _welders == null || _cutters == null || _torpDock == null) { return; } if (_cutters.Count == 0) { return; } _shipTag = ParseTag(_torpDock.CubeGrid.CustomName); _projector.CustomName = _shipTag + "_MTB_" + "Projector"; _timer.CustomName = _shipTag + "_MTB_" + "Timer"; //..setup timer actions automatically? _torpDock.CustomName = _shipTag + "_MTB_" + "TorpedoDock"; _piston.CustomName = _shipTag + "_MTB_" + "Piston"; //..name the welders for (int i = 0; i < _welders.Count; ++i) { IMyShipWelder w = _welders[i]; w.Enabled = false; w.CustomName = _shipTag + "_MTB_" + "Welder_" + (i + 1); } //..make sure all the cutters are off to begin with for (int i = 0; i < _cutters.Count; ++i) { IMyThrust t = _cutters[i]; t.ThrustOverridePercentage = 1; t.Enabled = false; t.CustomName = _shipTag + "_MTB_" + "Cutter_" + (i + 1); } }
public Program() { // fill pistons dictionary { string[] strPistonNames = new string[9]; strPistonNames[0] = "Piston_top_down"; strPistonNames[1] = "Piston_top_up"; strPistonNames[2] = "Piston_module_creation_top_1"; strPistonNames[3] = "Piston_module_creation_top_2"; strPistonNames[4] = "Piston_module_grabber_side"; strPistonNames[5] = "Piston_module_grabber_front"; strPistonNames[6] = "Piston_module_grabber_back"; strPistonNames[7] = "Piston_holder_front"; strPistonNames[8] = "Piston_holder_back"; for (int i = 0; i < strPistonNames.Length; i++) { if ((GridTerminalSystem.GetBlockWithName(strPistonNames[i]) as IMyPistonBase) == null) { throw new Exception("Error - Piston with name: " + strPistonNames[i] + " does not exist!"); } Pistons.Add(strPistonNames[i], new Piston(strPistonNames[i], this)); } } // fill merge blocks dictionary { string[] strMergeBlocks = new string[5]; strMergeBlocks[0] = "Merge_module_creation"; strMergeBlocks[1] = "Merge_module_grabber_front"; strMergeBlocks[2] = "Merge_module_grabber_back"; strMergeBlocks[3] = "Merge_holder_front"; strMergeBlocks[4] = "Merge_holder_back"; for (int i = 0; i < strMergeBlocks.Length; i++) { if ((GridTerminalSystem.GetBlockWithName(strMergeBlocks[i]) as IMyShipMergeBlock) == null) { throw new Exception("Error - Merge Block with name: " + strMergeBlocks[i] + " does not exist!"); } MergeBlocks.Add(strMergeBlocks[i], new MergeBlock(strMergeBlocks[i], this)); } } // fill drills list GridTerminalSystem.GetBlocksOfType <IMyShipDrill>(Drills); if (Drills.Count == 0) { throw new Exception("No attached drills detected"); } // initialize connectors { string connectorTopName = "Connector_base"; connectorDrillTop = new Connector(connectorTopName, this); if (!connectorDrillTop.isValid) { throw new Exception("Connector with the name " + connectorTopName + " does not exist"); } // drill connector only needed for first module // after first module this connector should be replaced with the top connector // of the last added module - see StateMachine.StatePrepareForNewModule.Perform() string connectorBottomName = "Connector_drill"; connectorDrillBottom = new Connector(connectorBottomName, this); if (!connectorDrillBottom.isValid) { throw new Exception("Connector with the name " + connectorBottomName + " does not exist"); } } // initialize welder { Welder = GridTerminalSystem.GetBlockWithName("Welder_module_creation") as IMyShipWelder; if (Welder == null) { throw new Exception("Welder with the name Welder_module_creation does not exist"); } } // initialize Rotor { string rotorName = "Rotor_drills"; Rotor = GridTerminalSystem.GetBlockWithName(rotorName) as IMyMotorStator; if (Rotor == null) { Echo("Rotor with the name " + rotorName + " not found"); } } // initialize states drillState = new States.DrillState(); moduleBuildState = new States.ModuleBuildState(); // initialize state machine stateMachine = new StateMachine(this); // load data if (!Load()) { Echo("could not load saved data - set state to default values"); // first start of script drillState.State = States.eDrillState.eInvalidMax; moduleBuildState.State = States.eModuleBuildState.eInvalidMax; connectorDrillBottom = new Connector("Connector_drill", this); } }