Advertisement
WhamyKaBlamy

Space Engineers Automatic Solar Panels

Nov 22nd, 2015
416
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.49 KB | None | 0 0
  1. decimal Best_Output;
  2.  
  3. bool Base_Found;
  4. bool Reverse;
  5. bool Reverse_Pause;
  6.  
  7. void Main(string argument)
  8. {
  9.     IMySolarPanel Solar_1 = GridTerminalSystem.GetBlockWithName("Solar1") as IMySolarPanel;
  10.     IMyMotorStator Rotor_Base = GridTerminalSystem.GetBlockWithName("Rotor Base") as IMyMotorStator;
  11.     IMyMotorStator Arm_1 = GridTerminalSystem.GetBlockWithName("Arm 1") as IMyMotorStator;
  12.     IMyMotorStator Arm_2 = GridTerminalSystem.GetBlockWithName("Arm 2") as IMyMotorStator;
  13.     IMyTimerBlock Check_Timer = GridTerminalSystem.GetBlockWithName("Check Timer") as IMyTimerBlock;
  14.     IMyTimerBlock Angle_Timer = GridTerminalSystem.GetBlockWithName("Angle Timer") as IMyTimerBlock;
  15.     List<string> Solar_Info;
  16.     Solar_Info = new List<string>(Solar_1.DetailedInfo.Split(new string[] {" ","\n","\r"}, StringSplitOptions.None));
  17.    
  18.     if(argument == "Check")
  19.     {
  20.         Best_Output = Convert.ToDecimal(Solar_Info[5]);
  21.         if(Best_Output < (decimal)115.00)
  22.         {
  23.             Base_Found = false;
  24.             Reverse = false;
  25.             Reverse_Pause = false;
  26.             Rotor_Base.GetActionWithName("OnOff_On").Apply(Rotor_Base);
  27.             Angle_Timer.GetActionWithName("Start").Apply(Angle_Timer);
  28.         }
  29.         else
  30.         {
  31.             Check_Timer.GetActionWithName("Start").Apply(Check_Timer);
  32.         }  
  33.     }
  34.     else if(argument == "Angle")
  35.     {
  36.         decimal Output = Convert.ToDecimal(Solar_Info[5]);
  37.         if(Base_Found == false)
  38.         {    
  39.             if(Reverse == false)
  40.             {
  41.                 if(Output > Best_Output)
  42.                 {
  43.                     Best_Output = Output;
  44.                     Angle_Timer.GetActionWithName("Start").Apply(Angle_Timer);
  45.                 }
  46.                 else
  47.                 {
  48.                     Rotor_Base.GetActionWithName("Reverse").Apply(Rotor_Base);
  49.                     Reverse = true;
  50.                     Angle_Timer.GetActionWithName("Start").Apply(Angle_Timer);
  51.                 }
  52.             }
  53.             else
  54.             {
  55.                 if(Reverse_Pause == false)
  56.                 {
  57.                     Reverse_Pause = true;
  58.                     Angle_Timer.GetActionWithName("Start").Apply(Angle_Timer);
  59.                 }
  60.                 else
  61.                 {
  62.                     if(Output > Best_Output)
  63.                     {
  64.                         Best_Output = Output;
  65.                         Angle_Timer.GetActionWithName("Start").Apply(Angle_Timer);
  66.                     }
  67.                     else
  68.                     {
  69.                         Rotor_Base.GetActionWithName("OnOff_Off").Apply(Rotor_Base);
  70.                         Arm_1.GetActionWithName("OnOff_On").Apply(Arm_1);
  71.                         Arm_2.GetActionWithName("OnOff_On").Apply(Arm_2);
  72.                         Reverse = false;
  73.                         Reverse_Pause = false;
  74.                         Base_Found = true;
  75.                         Angle_Timer.GetActionWithName("Start").Apply(Angle_Timer);
  76.                     }
  77.                 }
  78.             }
  79.         }
  80.         else
  81.         {
  82.             if(Reverse == false)
  83.             {
  84.                 if(Output > Best_Output)
  85.                 {
  86.                     Best_Output = Output;
  87.                     Angle_Timer.GetActionWithName("Start").Apply(Angle_Timer);
  88.                 }
  89.                 else
  90.                 {
  91.                     Arm_1.GetActionWithName("Reverse").Apply(Arm_1);
  92.                     Arm_2.GetActionWithName("Reverse").Apply(Arm_2);
  93.                     Reverse = true;
  94.                     Angle_Timer.GetActionWithName("Start").Apply(Angle_Timer);
  95.                 }
  96.             }
  97.             else
  98.             {
  99.                 if(Reverse_Pause == false)
  100.                 {
  101.                     Reverse_Pause = true;
  102.                     Angle_Timer.GetActionWithName("Start").Apply(Angle_Timer);
  103.                 }
  104.                 else
  105.                 {
  106.                     if(Output > Best_Output)
  107.                     {
  108.                         Best_Output = Output;
  109.                         Angle_Timer.GetActionWithName("Start").Apply(Angle_Timer);
  110.                     }
  111.                     else
  112.                     {
  113.                         Arm_1.GetActionWithName("OnOff_Off").Apply(Arm_1);  
  114.                         Arm_2.GetActionWithName("OnOff_Off").Apply(Arm_2);
  115.                         Check_Timer.GetActionWithName("Start").Apply(Check_Timer);
  116.                     }
  117.                 }
  118.             }
  119.         }
  120.     }
  121. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement