Suicide_Jack

PDS v0.5

Aug 8th, 2017
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.00 KB | None | 0 0
  1. /*
  2. * Original author: GreenPixel , ultra precice speed controll
  3. * Edited or butchered by Suicide_Jack
  4. * Setup:
  5. * 1 place Programmable block name it "PDS Controller"
  6. * 2 rename one or more thruster that thrusts forward "PDS Thruster"
  7. * 3 setup timer block that triggers itself and this script
  8. *
  9. */
  10.  
  11.  
  12.  
  13. List<IMyTerminalBlock> blocks = new List<IMyTerminalBlock>();
  14. double x0,dx;
  15. double y0,dy;
  16. double z0,dz;
  17. double speed;
  18. double setSpeed=0.006; //0.016~1m/s (perfect speed for drilling 0.1-0.3m/s)
  19. double speedMultiplier=288000; //max. thruster force (in N)
  20. float Thrust;
  21. bool active = false; //Whether the PDS is active.
  22.  
  23.  
  24. public void Main(string argument)
  25. {
  26. switch (argument)
  27. {
  28. case "stop":
  29. active = false;
  30. break;
  31. case "start":
  32. active = true;
  33. return;
  34. }
  35.  
  36.  
  37.  
  38. GridTerminalSystem.SearchBlocksOfName("PDS Controller",blocks);
  39. if(blocks.Count<1)
  40. {
  41. Echo("PDS Controller not found!");
  42. return;
  43. }
  44.  
  45. Vector3D vPos=Me.GetPosition();
  46. double x = Math.Round(vPos.X,3);
  47. double y = Math.Round(vPos.Y,3);
  48. double z = Math.Round(vPos.Z,3);
  49.  
  50. dx=x-x0;dy=y-y0;dz=z-z0;x0=x;y0=y;z0=z;
  51. speed=Math.Round(Math.Sqrt(dx*dx+dy*dy+dz*dz),5);
  52.  
  53. Thrust=(float)(setSpeed-speed)*(float)speedMultiplier;
  54.  
  55. GridTerminalSystem.SearchBlocksOfName("PDS Thruster",blocks);
  56.  
  57.  
  58. if (active == true)
  59. {
  60. for(int i=0;i<blocks.Count;i++)
  61. {
  62. blocks[i].SetValueFloat("Override",Thrust);
  63. }
  64. return;
  65. }
  66. else
  67. {
  68. for(int i=0;i<blocks.Count;i++)
  69. {
  70. blocks[i].SetValueFloat("Override",0);
  71. }
  72. return;
  73. }
  74. }
Advertisement
Add Comment
Please, Sign In to add comment