Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Space Engineers - Symple Hydrogen Trade scrips v0.1 by swagman //instruction: https://youtu.be/uOwzDUgW4z4
- public Program() { Runtime.UpdateFrequency = UpdateFrequency.Update10; }
- float LitersPerSC = 7; //price
- double LitersOld;
- 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);
- var tn = GridTerminalSystem.GetBlockWithName("!Tank") as IMyGasTank;
- var sc = GridTerminalSystem.GetBlockWithName("!Connector") as IMyShipConnector;
- MyItemType Сurrency = new MyItemType("MyObjectBuilder_PhysicalObject", "SpaceCredit");
- var LitersCurr = tn.Capacity * tn.FilledRatio;
- m.WriteText($"=HYDRO FUELING=\nHAVE:{LitersCurr:F0} L\n BY:{LitersPerSC} L/SC\n");
- if (sc.Status==MyShipConnectorStatus.Connected) {
- var oi = sc.OtherConnector.GetInventory();
- var cash = oi.GetItemAt(0);
- var money = cash?.Type==Сurrency ? cash?.Amount : 0;
- if (money==0) sc.Disconnect(); else {
- var diff = LitersOld - LitersCurr;
- int pay = (int)Math.Truncate(diff / LitersPerSC);
- sc.GetInventory().TransferItemFrom(oi, 0, null, true, pay );
- LitersOld = LitersCurr + (diff - pay * LitersPerSC);
- };
- m.WriteText($"CASH:{money} SC\n OR:{money*LitersPerSC} L",true);
- } else LitersOld = LitersCurr;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement