Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Notes:
- //Good settings are:
- //Pistons & Rotor Force of 22.8kn
- //Rotor 1.07 RPM
- //Rotor Torque and Breaking Torque maxed out
- //Timer set to 30 seconds
- string Go_Timer_Name = "Pistons_Timer_Go"; //Change this to the name of the timer used to control everything
- //The timer should be set to 30 seconds and to pass an argument of "Go"
- //to the progammable block
- string Rotor_Name = "Pistons_Rotor"; //Name of the rotor that the drills are attached to
- void Main(string Argument)
- {
- List<IMyPistonBase> Pistons = new List<IMyPistonBase>();
- GridTerminalSystem.GetBlocksOfType<IMyPistonBase>(Pistons);
- bool Active = false;
- if(Argument == "Go")
- {
- for(int i = 0; i < Pistons.Count ; i++)
- {
- if(Active == false)
- {
- if(Pistons[i].Velocity < 0.0)
- {
- Pistons[i].GetActionWithName("IncreaseVelocity").Apply(Pistons[i]);
- }
- if(Pistons[i].Velocity > 0.0)
- {
- List <String>Pistons_Info = new List<String>(Pistons[i].DetailedInfo.Split(new string[] {" ","\n","\r","m"}, StringSplitOptions.None));
- decimal Extension = Math.Round(Convert.ToDecimal(Pistons_Info[4]),1);
- decimal Max_Limit = Math.Round((decimal)Pistons[i].MaxLimit,1);
- if( Max_Limit < 10 && Extension == Max_Limit)
- {
- Pistons[i].GetActionWithName("IncreaseUpperLimit").Apply(Pistons[i]);
- Active = true;
- }
- else if( Max_Limit < 10 || Extension < 10)
- {
- Active = true;
- }
- }
- }
- }
- if(Active == true)
- {
- GoTimer();
- }
- }
- if(Argument == "Stop" || Active == false)
- {
- IMyTimerBlock Timer = GridTerminalSystem.GetBlockWithName(Go_Timer_Name) as IMyTimerBlock;
- Timer.GetActionWithName("Stop").Apply(Timer);
- IMyMotorStator Rotor = GridTerminalSystem.GetBlockWithName(Rotor_Name) as IMyMotorStator;
- Rotor.GetActionWithName("OnOff_Off").Apply(Rotor);
- List<IMyShipDrill> Drills = new List<IMyShipDrill>();
- GridTerminalSystem.GetBlocksOfType<IMyShipDrill>(Drills);
- for( int d = 0; d<Drills.Count ; d++)
- {
- Drills[d].GetActionWithName("OnOff_Off").Apply(Drills[d]);
- }
- for(int i = 0; i<Pistons.Count; i++)
- {
- if(Pistons[i].Velocity > 0.0)
- {
- Pistons[i].GetActionWithName("DecreaseVelocity").Apply(Pistons[i]);
- }
- for(int x=0; x<20; x++)
- {
- Pistons[i].GetActionWithName("DecreaseUpperLimit").Apply(Pistons[i]);
- }
- }
- }
- }
- void GoTimer()
- {
- IMyTimerBlock Timer = GridTerminalSystem.GetBlockWithName(Go_Timer_Name) as IMyTimerBlock;
- Timer.GetActionWithName("Start").Apply(Timer);
- }
Add Comment
Please, Sign In to add comment