Advertisement
Saberwulfy

Control Module Test001

Apr 21st, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.88 KB | None | 0 0
  1. const string RotorNameX = "Rotor Horizontal"; // the rotor names
  2. const string RotorNameY = "Rotor Vertical";
  3. int divisor = 1;
  4.  
  5. void Main(string arg)
  6. {
  7.     var inputs = Me.GetValue<Dictionary<string, object>>("ControlModule.Inputs");
  8.    
  9.     var rotorX = GridTerminalSystem.GetBlockWithName(RotorNameX) as IMyMotorStator;
  10.     var rotorY = GridTerminalSystem.GetBlockWithName(RotorNameY) as IMyMotorStator;
  11.    
  12.     if(rotorX == null || rotorY == null) // when the ship gets split the rotors might not get found, that's why no error here
  13.         return;
  14.    
  15.     var mouse = (Vector3)inputs["m.analog"];
  16.        
  17.     // travando velocidade maxima do mouse
  18.     mouse.X = MathHelper.Clamp(mouse.X, - 10, 10);
  19.     mouse.Y = MathHelper.Clamp(mouse.Y, - 10, 10);
  20.    
  21.     //pegando as teclas 1 2 3 4
  22.     bool zoomOne = inputs.ContainsKey("num1"); // you can edit controls used here
  23.     bool zoomTwo = inputs.ContainsKey("num2");
  24.     bool zoomFour = inputs.ContainsKey("num3");
  25.    
  26.     // selecionando velocidade do zoom, selecting turret speed
  27.     if(zoomOne == true) divisor = 1; else return;
  28.     if(zoomTwo == true) divisor = 2; else return;
  29.     if(zoomFour == true) divisor = 3; else return;
  30.    
  31.     // depending on how your rotors are set up you might need to invert the values
  32.     // to do that simply add - in front of mouse.X or mouse.Y
  33.     rotorX.SetValueFloat("Velocity", mouse.X/divisor);
  34.     rotorY.SetValueFloat("Velocity", mouse.Y/divisor);
  35.        
  36.     // escrevendo em um lcd o nivel do zoom, writing turret speed in a lcd
  37.     IMyTextPanel panel = GridTerminalSystem.GetBlockWithName("Text panel Zoom") as IMyTextPanel;
  38.     if(divisor == 1){
  39.         string text = "Zoom speed 100%";
  40.         panel.WritePublicText(text, false);
  41.         }
  42.     if(divisor == 2){
  43.         string text = "Zoom speed 50%";
  44.         panel.WritePublicText(text, false);    
  45.         }
  46.     if(divisor == 4){
  47.         string text = "Zoom speed 25%";
  48.         panel.WritePublicText(text, false);
  49.         }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement