Advertisement
drabont

Space Engineers - Symple Hydrogen Trade

Apr 17th, 2021
1,267
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.42 KB | None | 0 0
  1. //Space Engineers - Symple Hydrogen Trade scrips v0.1 by swagman //instruction: https://youtu.be/uOwzDUgW4z4
  2. public Program() { Runtime.UpdateFrequency = UpdateFrequency.Update10; }
  3.  
  4. float LitersPerSC = 7; //price
  5. double LitersOld;
  6.  
  7. public void Main(string arg) {/*mon init*/var m = Me.GetSurface(0); m.ContentType = ContentType.TEXT_AND_IMAGE; m.FontSize = 26.4f/15; m.TextPadding = 0;m.Font = "Monospace"; m.FontColor = Color.Gray; m.BackgroundColor = new Color(0,0,7);
  8.  
  9.   var tn = GridTerminalSystem.GetBlockWithName("!Tank") as IMyGasTank;
  10.   var sc = GridTerminalSystem.GetBlockWithName("!Connector") as IMyShipConnector;
  11.  
  12.   MyItemType –°urrency = new MyItemType("MyObjectBuilder_PhysicalObject", "SpaceCredit");
  13.  
  14.   var LitersCurr = tn.Capacity * tn.FilledRatio;
  15.   m.WriteText($"=HYDRO FUELING=\nHAVE:{LitersCurr:F0} L\n  BY:{LitersPerSC} L/SC\n");
  16.  
  17.   if (sc.Status==MyShipConnectorStatus.Connected) {
  18.     var oi = sc.OtherConnector.GetInventory();
  19.     var cash = oi.GetItemAt(0);
  20.     var money = cash?.Type==–°urrency ? cash?.Amount : 0;
  21.     if (money==0) sc.Disconnect(); else {
  22.       var diff = LitersOld - LitersCurr;
  23.       int pay = (int)Math.Truncate(diff / LitersPerSC);
  24.       sc.GetInventory().TransferItemFrom(oi, 0, null, true, pay );
  25.       LitersOld = LitersCurr + (diff - pay * LitersPerSC);
  26.     };
  27.     m.WriteText($"CASH:{money} SC\n  OR:{money*LitersPerSC} L",true);
  28.   } else LitersOld = LitersCurr;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement