Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * ultra precice speed controll
- * butchered by Suicide_Jack
- * Setup:
- * 1 place Programmable block and name it "PDS Controller"
- * 2 rename one or more thruster that thrusts forward "PDS-Thruster"
- * 3 setup timer block that triggers itself and this script
- *
- */
- List<IMyTerminalBlock> blocks = new List<IMyTerminalBlock>();
- double x0,dx;
- double y0,dy;
- double z0,dz;
- double speed;
- double setSpeed=0.006; //0.016~1m/s (perfect speed for drilling 0.1-0.3m/s)
- double speedMultiplier=288000; //max. thruster force (in N)
- float Thrust;
- bool active = false; //Whether the PDS is active.
- public void Main(string argument)
- {
- switch (argument)
- {
- case "stop":
- active = false;
- break;
- case "start":
- active = true;
- return;
- }
- GridTerminalSystem.SearchBlocksOfName("Controller PDS",blocks);
- if(blocks.Count<1)
- {
- Echo("PDS Controller not found!");
- return;
- }
- Vector3D vPos=Me.GetPosition();
- double x = Math.Round(vPos.X,3);
- double y = Math.Round(vPos.Y,3);
- double z = Math.Round(vPos.Z,3);
- dx=x-x0;dy=y-y0;dz=z-z0;x0=x;y0=y;z0=z;
- speed=Math.Round(Math.Sqrt(dx*dx+dy*dy+dz*dz),5);
- Thrust=(float)(setSpeed-speed)*(float)speedMultiplier;
- GridTerminalSystem.SearchBlocksOfName("PDS-Thruster",blocks);
- if (active == true)
- {
- for(int i=0;i<blocks.Count;i++)
- {
- blocks[i].SetValueFloat("Override",Thrust);
- }
- return;
- }
- else
- {
- for(int i=0;i<blocks.Count;i++)
- {
- blocks[i].SetValueFloat("Override",0);
- }
- return;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment