Whiplash141

GPS Recorder for Erebus Alpha

Jun 6th, 2017
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.41 KB | None | 0 0
  1. //Whip's GPS Recorder v1 - 6/6/17
  2. //Made for Erebus Alpha :)
  3.  
  4. string textPanelNameTag = "GPS";
  5.  
  6. void Main(string arg)
  7. {
  8.     var coordList = Me.CustomData.Split(new char[] { '\n', '\r' });
  9.  
  10.     int count = 1;
  11.     foreach (var thisCoord in coordList)
  12.     {
  13.         var gpsSplit = thisCoord.Split(':');
  14.         if (gpsSplit.Length != 6)
  15.         {
  16.             if (!string.IsNullOrWhiteSpace(thisCoord))
  17.                 Echo($"Error: '{thisCoord}' is not a GPS coordinate");
  18.             continue;
  19.         }
  20.         var name = gpsSplit[1];
  21.         if (name.Contains(arg))
  22.         {
  23.             count++;
  24.         }
  25.     }
  26.     var currentPos = GetWorldPosition(Me);
  27.     var gpsString = "GPS:" + arg + String.Format("{0:000}", count) + $":{Math.Round(currentPos.X)}:{Math.Round(currentPos.Y)}:{Math.Round(currentPos.Z)}:\n";
  28.     Me.CustomData += gpsString;
  29.  
  30.     var screens = new List<IMyTextPanel>();
  31.     GridTerminalSystem.GetBlocksOfType(screens, x => x.CustomName.ToLower().Contains(textPanelNameTag.ToLower()));
  32.  
  33.     if (screens.Count == 0)
  34.     {
  35.         Echo($"Warning: No text panels named '{textPanelNameTag} were found'");
  36.         return;
  37.     }
  38.  
  39.     foreach (var block in screens)
  40.     {
  41.         block.WritePublicText(Me.CustomData);
  42.         block.ShowPublicTextOnScreen();
  43.     }
  44. }
  45.  
  46. Vector3D GetWorldPosition(IMyTerminalBlock block)
  47. {
  48.     return block.CubeGrid.GridIntegerToWorld(block.Position);
  49. }
Advertisement
Add Comment
Please, Sign In to add comment