private void getCounts(string itemstring) { int count = 0; List <IMyCargoContainer> containers = new List <IMyCargoContainer>(); GridTerminalSystem.GetBlocksOfType(containers, (IMyCargoContainer block) => block.HasInventory); //Echo("Found " + containers.Count.ToString() + " containers"); for (int i = 0; i < containers.Count; i++) { IMyCargoContainer cont = containers[i]; List <MyInventoryItem> items = new List <MyInventoryItem>(); if (cont.HasInventory) { IMyInventory cont_inv = cont.GetInventory() as IMyInventory; cont_inv.GetItems(items, (MyInventoryItem item) => item.Type.ToString() == itemstring); //Echo("Found " + items.Count.ToString() + " items in " + cont.Name); for (int j = 0; j < items.Count; j++) { var item = items[j]; count += item.Amount.ToIntSafe(); } } } counts[itemstring] = count; }
public findStorageCapacity() { string cargoGroupName = "Base Cargo"; string LCDName = "[MCD] Cargo"; IMyBlockGroup cargos = GridTerminalSystem.GetBlockGroupWithName(cargoGroupName); List <IMyTerminalBlock> blocks = new List <IMyTerminalBlock>(); cargos.GetBlocks(blocks); float capacity = 0; float usage = 0; foreach (var block in blocks) { IMyCargoContainer cargo = block as IMyCargoContainer; capacity += (float)cargo.GetInventory(0).MaxVolume; usage += (float)cargo.GetInventory(0).CurrentVolume; } float pctUsed = 100.0f * usage / capacity; IMyTextSurface lcd = GridTerminalSystem.GetBlockWithName(LCDName) as IMyTextSurface; // If we found that LCD, let's write the graph to it. if (lcd != null) { // Start the display text with a title and our space used in %. string displayText = String.Format("Capacity\nOverall: {0}%\n", (int)pctUsed); // Build the graph from the top down. for (int x = 0; x <= 10; x++) { if (pctUsed >= 100 - x * 10) { displayText += " | ----- |\n"; } else { displayText += " | |\n"; } } // Show the result on the LCD. //lcd.ShowTextureOnScreen(); lcd.ContentType = ContentType.TEXT_AND_IMAGE; lcd.FontSize = 2; lcd.WriteText(displayText, false); //lcd.ShowPublicTextOnScreen(); } /* * // Now let's find the warning sign. * lcd = GridTerminalSystem.GetBlockWithName(warningName) as IMyTextPanel; * * // If we found the warning sign, decide whether to have it turned on or off. * if (lcd != null) { * // If we've used more than 80% of our cargo, have it turn on. Else, have it turn off. * if (pctUsed > 80) { * lcd.ApplyAction("OnOff_On"); * } else { * lcd.ApplyAction("OnOff_Off"); * } * } */ }
// // http://steamcommunity.com/sharedfiles/filedetails/?id=360966557 // https://forum.keenswh.com/threads/pb-scripting-guide-how-to-use-self-updating.7398267/ // //---------------------------------------------------------------------------------------------------------------------- // Kopioitava koodi //---------------------------------------------------------------------------------------------------------------------- void Main() { // ------------ Auto update --------------- Runtime.UpdateFrequency = UpdateFrequency.Update10; // ------------ Definitions --------------- IMyTextPanel naytto1 = GridTerminalSystem.GetBlockWithName("Infoscreen") as IMyTextPanel; IMyCargoContainer cargo1 = GridTerminalSystem.GetBlockWithName("Hitsi cargo 1") as IMyCargoContainer; // ------------ Logic --------------- // --- Cargo 1 usage --- float usedVolume1 = 0.0f; float maxVolume1 = 0.0f; usedVolume1 = (float)cargo1.GetInventory(0).CurrentVolume; maxVolume1 += (float)cargo1.GetInventory(0).MaxVolume; float pctUsed1 = 100.0f * usedVolume1 / maxVolume1; // ------------ Screen writing --------------- naytto1.WritePublicText("\n\n\n\n Cargo-1 käytössä: " + (int)pctUsed1 + "%", false); naytto1.ShowPublicTextOnScreen(); }
public static MyFixedPoint MoveItem(IMyCargoContainer from, IMyCargoContainer to, string type, MyFixedPoint?amount) { MyFixedPoint amountmoved = new MyFixedPoint(); MyInventoryItem?item; bool moved; for (int i = from.GetInventory(0).ItemCount; i >= 0; i--) { item = from.GetInventory(0).GetItemAt(i); if (item.HasValue && item.Value.Type.SubtypeId == type) { MyFixedPoint amounttomove = amount.HasValue ? MyFixedPoint.Min(amount.Value - amountmoved, item.Value.Amount) : item.Value.Amount; moved = to.GetInventory(0).TransferItemFrom(from.GetInventory(0), item.Value, amounttomove); if (!moved) { return(amountmoved); } amountmoved += amounttomove; if (amountmoved >= amount) { return(amountmoved); } } } return(amountmoved); }
public Container(IMyCargoContainer block) { _cargo = block; string[] options = _cargo.CustomData.Split(SPLIT_OPTIONS_CHAR, StringSplitOptions.RemoveEmptyEntries); foreach (string option in options) { string[] kV = option.Split('='); if (kV.Length == 2) { string[] values = kV[1].Split(SPLIT_VALUES_CHAR, StringSplitOptions.RemoveEmptyEntries); if (kV[0] == "types") { foreach (string value in values) { string val = value[0].ToString().ToUpper() + value.Substring(1); ItemType type; if (Enum.TryParse(val, out type)) { _containedTypes.Add(type); } } } else if (kV[0] == "subtypes") { _containedSubtypes.UnionWith(values.ToList().ConvertAll(value => value.ToLower())); } } } }
public void CheckProductionNeed(ref List <ControlObject> controlObjectList, ref FinalContainer finalContainer) { IMyGridTerminalSystem myGridTerminalSystem = null; IMyCargoContainer finalContainerUnico = null; foreach (ControlObject controlObject in controlObjectList) { MyItemType item = new MyItemType(controlObject.getComponentIDValue(), ""); for (int i = 0; i < finalContainer.getContainerName().Count(); i++) { finalContainerUnico = (IMyCargoContainer)myGridTerminalSystem.GetBlockWithName(finalContainer.getContainerName()[i]); if (finalContainerUnico != null) { MyInventoryItem myInventoryItem = (MyInventoryItem)finalContainerUnico.GetInventory().FindItem(item); if (myInventoryItem != null) { controlObject.setComponentsAmountProduced((int)myInventoryItem.Amount); controlObject.setComponentsAmountToProduce(controlObject.getComponetAmountKeepStorage() - controlObject.getComponentsAmountProduced()); } else { controlObject.setComponentsAmountProduced(controlObject.getComponetAmountKeepStorage()); controlObject.setComponentsAmountToProduce(controlObject.getComponetAmountKeepStorage()); } } } } }
private void ViewCargoInventory(IMyCargoContainer cargo) { if (cargo == null) { Print("Контейнер не найден"); return; } Print($"Контейнер: {cargo.CustomName}"); IMyInventory inventory = cargo.GetInventory(); if (inventory != null) { Print($"items: {inventory.GetItems().Count}"); foreach (var item in inventory.GetItems()) { Print( $"{cargo.CustomName} \n\t\tN: {item.Content.SubtypeName}, \n\t\tI: {item.Content.SubtypeId}, \n\t\tT: {item.Content.TypeId}"); } } else { Print("Конейнер пуст"); } }
private float GetCargoSpace(List <IMyTerminalBlock> cargoContainers = null) { float result = 0; int count = 0; var source = cargoContainers ?? new List <IMyTerminalBlock>(); if (cargoContainers == null) { GridTerminalSystem.GetBlocksOfType <IMyCargoContainer>(source); } for (int i = 0; i < source.Count; i++) { IMyCargoContainer cargoContainer = source[i] as IMyCargoContainer; if (cargoContainer == null) { continue; } IMyInventory inventory = cargoContainer.GetInventory(0); float currentVolume = inventory.CurrentVolume.RawValue; float maxVolume = inventory.MaxVolume.RawValue; result += currentVolume / maxVolume; DebugString.AppendLine(string.Format("{0} / {1} = {2}", currentVolume, maxVolume, currentVolume / maxVolume)); count++; } return(count != 0 ? result / count : 0f); }
public void Main(string containerName) { IMyCargoContainer cargo = FindBlock <IMyCargoContainer>(containerName); IMyTextPanel debug = FindBlock <IMyTextPanel>("debug"); if (cargo == null || debug == null) { debug.WritePublicText("Cargo or debug not found!", false); return; } IMyInventory cargoInventory = cargo.GetInventory(0); var assemblers = new List <IMyTerminalBlock>(); GridTerminalSystem.GetBlocksOfType <IMyAssembler>(assemblers); for (int i = 0; i < assemblers.Count; i++) { if (!assemblers[i].HasInventory) { continue; } IMyInventory inventory = assemblers[i].GetInventory(1); List <IMyInventoryItem> items = inventory.GetItems(); debug.WritePublicText("Items Moved:" + items.Count + "\n", true); // Move items to cargo for (int j = 0; j < items.Count; j++) { inventory.TransferItemTo(cargoInventory, 0, null, stackIfPossible: true); } } }
public Program() { m_MainCargoContainer = GridTerminalSystem.GetBlockWithName(MainCargoName) as IMyCargoContainer; m_ToolsCargoContainer = GridTerminalSystem.GetBlockWithName(ToolsCargoName) as IMyCargoContainer; GridTerminalSystem.GetBlocksOfType(m_Assemblers, a => (a is IMyAssembler && a.CubeGrid == m_MainCargoContainer.CubeGrid)); GridTerminalSystem.GetBlocksOfType(m_Refineries, a => (a is IMyRefinery && a.CubeGrid == m_MainCargoContainer.CubeGrid)); m_MainAssembler = m_Assemblers.First(a => a.CustomName == MainAssemblerName); m_MainGasGenerator = GridTerminalSystem.GetBlockWithName(MainGasGeneratorName) as IMyGasGenerator; m_FrontLcdOres = GridTerminalSystem.GetBlockWithName(OresIngotsLcdName) as IMyTextSurface; m_FrontLcdComponents = GridTerminalSystem.GetBlockWithName(ComponentsLcdName) as IMyTextSurface; #region Лист заказов кроме стальных пластин m_OrderList = new List <MyItemType>(); m_OrderList.Add(TypeInteriorPlate); m_OrderList.Add(TypeConstructionComponent); m_OrderList.Add(TypeMetalGrid); m_OrderList.Add(TypeComputer); m_OrderList.Add(TypeLargeTube); m_OrderList.Add(TypeSmallTube); m_OrderList.Add(TypeMotor); m_OrderList.Add(TypeDisplay); m_OrderList.Add(TypePowerCell); m_OrderList.Add(TypeGirder); m_OrderList.Add(TypeDetector); m_OrderList.Add(TypeRadioCommunication); m_OrderList.Add(TypeBulletproofGlass); #endregion Runtime.UpdateFrequency = UpdateFrequency.Update100; }
private void UnloadCargo() { if (m_Connector.Status == MyShipConnectorStatus.Connected) { if (m_MainCargoContainer == null) { m_MainCargoContainer = GridTerminalSystem.GetBlockWithName(UnloadCargoName) as IMyCargoContainer; } if (m_MainCargoContainer != null) { var mainInventory = m_MainCargoContainer.GetInventory(0); foreach (var pair in m_AllBlocks) { var container = pair.Key as IMyCargoContainer; if (container != null) { var inventory = container.GetInventory(0); while (inventory.ItemCount != 0) { mainInventory.TransferItemFrom(inventory, 0, null, true); } } } } } }
private bool empty(IMyTerminalBlock cube) { List <MyInventoryItem> li = new List <MyInventoryItem>(); IMyInventory src = cube.GetInventory(); src.GetItems(li); foreach (MyInventoryItem item in li) { //Echo("Trying to move "+item.Amount.ToIntSafe()+" of "+item.Type.SubtypeId+" from "+cube.CustomName); IMyCargoContainer box = getTargetToFill(); //Echo("Checking "+box.CustomName); IMyInventory tgt = box.GetInventory(); if (tryMove(src, tgt, item)) { Echo("Moved " + item.Amount.ToIntSafe() + " of " + item.Type.SubtypeId + " from " + cube.CustomName + " to " + box.CustomName); currentPreferredTarget = box; return(true); } else { currentPreferredTarget = null; } } return(false); }
public void setupContainerDict(IMyCargoContainer container) { bool found = false; List <IMyCargoContainer> tempList = new List <IMyCargoContainer>(); IMyInventory tempInv = container.GetInventory(); string volumeString = ""; if ((float)tempInv.CurrentVolume > 0.0f) { volumeString = " (" + (((float)tempInv.CurrentVolume / (float)tempInv.MaxVolume) * 100.0f).ToString("N1") + "%)"; } else { volumeString = " (0%)"; } foreach (string vString in CargoPrefix) { if (!(container_dict.ContainsKey(vString))) { container.CustomName = vString + " Cargo Container 01" + volumeString; tempList.Add(container); container_dict.Add(vString, tempList); found = true; break; } } if (!(found)) { Echo("Dict already contains the proper key.\n" + container.CustomName + " is lost"); } }
private IMyCargoContainer getTargetToFill() { if (currentPreferredTarget != null && currentPreferredTarget.GetInventory().IsFull) { currentPreferredTarget = null; } return(currentPreferredTarget != null ? currentPreferredTarget : getRandom(containersToFill)); }
bool FuncTest(IMyCargoContainer block) { //Small Cargo Container //Medium Cargo Container //Large Cargo Container //Interface name: IMyCargoContainer return(true); }
public Program() { Runtime.UpdateFrequency = UpdateFrequency.Update10; Container1 = GridTerminalSystem.GetBlockWithName("cargo") as IMyCargoContainer; SALCD = GridTerminalSystem.GetBlockWithName("mon ecran") as IMyTextPanel; }
public Program() { Runtime.UpdateFrequency = UpdateFrequency.Update10; AssemblerQueue = GridTerminalSystem.GetBlockWithName("Assembler BuildList") as IMyAssembler; WelderContainer = GridTerminalSystem.GetBlockWithName("Welder Container") as IMyCargoContainer; //This need to be change to get all invetory on welding ship, including connectors, welders and containers CargoContainers = GridTerminalSystem.GetBlockWithName("Small Cargo Container") as IMyCargoContainer; //This need to be change to exclude inventories on welding ship and take stuff from inventory at base WelderLCD = GridTerminalSystem.GetBlockWithName("LCD Welder") as IMyTextPanel; ErrorLCD = GridTerminalSystem.GetBlockWithName("LCD Error") as IMyTextPanel; }
public CargoContainer(string oBlockName) { m_oBlock = gts.GetBlockWithName(oBlockName) as IMyCargoContainer; if (m_oBlock == null) { throw new Exception(oBlockName + " block not found, check name"); } Init(m_oBlock); }
/// <summary> /// Sorter cache /// </summary> /// <returns></returns> public Cargo EnableCache() { // nutny blok Cache = Instance.GetListByName <IMyCargoContainer>("_Cache", true).First(); // definice List <MyInventoryItem> components = new List <MyInventoryItem>(); List <MyInventoryItem> cache = new List <MyInventoryItem>(); MyFixedPoint amount = 0; Dictionary <string, MyFixedPoint> cached = new Dictionary <string, MyFixedPoint>(); // nacteni polozek Component.GetInventory(0).GetItems(components); Cache.GetInventory(0).GetItems(cache); // premapovani nakesovanych polozek foreach (MyInventoryItem item in cache) { cached.Add(item.Type.SubtypeId, item.Amount); } // presun polozek for (int i = components.Count - 1; i >= 0; i--) { // definice string localType = components[i].Type.SubtypeId; MyFixedPoint localAmount = components[i].Amount; // pokud se nejedna o nezadouci polozku a zaroven u v kesi neexistuje if (Constants.ComponentsToCache.Contains(localType)) { if (cached.ContainsKey(localType)) { amount = Constants.SorterCache - cached[localType]; } else { // vytvoreni polozky cached.Add(localType, 0); // urceni mnozstvi if (localAmount < Constants.SorterCache) { amount = localAmount; } else { amount = Constants.SorterCache; } } // presun do serteru if (amount > 0) { cached[localType] += amount; Component.GetInventory(0).TransferItemTo(Cache.GetInventory(0), i, null, true, amount); } } } // fluent return(this); }
public void PrintInventory(IMyCargoContainer Container, IMyTextPanel LCD) { string output = ""; for (int i = 0; i < Container.GetInventory(0).ItemCount; i++) { output += Container.GetInventory(0).GetItemAt(i).Value.Amount + " " + Container.GetInventory(0).GetItemAt(i).Value.Type.SubtypeId + "\n"; } LCD.ContentType = ContentType.TEXT_AND_IMAGE; LCD.WriteText(output); }
public static bool isConnectedToCargo(IMyCargoContainer container, List <IMyBlockGroup> groups) { foreach (IMyBlockGroup group in groups) { if (!isConnectedToCargo(container, group)) { return(false); } } return(true); }
public static bool isConnectedToCargo(IMyCargoContainer container, IReadOnlyCollection <IMyTerminalBlock> blocks) { foreach (IMyTerminalBlock block in blocks) { if (!isConnectedToCargo(container, block)) { return(false); } } return(true); }
public void ClearAssemblerQueue(IMyAssembler AssemblerQueue, IMyCargoContainer WelderContainer, IMyCargoContainer CargoContainers) //This clear queue in assebler and remove items from welding ship container { AssemblerQueue.ClearQueue(); for (int i = WelderContainer.GetInventory(0).ItemCount - 1; i >= 0; i--) { if (CargoContainers.GetInventory(0).CanItemsBeAdded(WelderContainer.GetInventory(0).GetItemAt(i).Value.Amount, WelderContainer.GetInventory(0).GetItemAt(i).Value.Type)) { WelderContainer.GetInventory(0).TransferItemTo(CargoContainers.GetInventory(0), WelderContainer.GetInventory(0).GetItemAt(i).Value); } } }
private void addtoContainer(IMyCargoContainer FoundCargoCont, SerializableDefinitionId item, int amount) { IMyInventory inventory = ((Sandbox.ModAPI.Ingame.IMyTerminalBlock)FoundCargoCont).GetInventory(0) as IMyInventory; if (!inventory.CanItemsBeAdded(amount, item)) { return; } MyFixedPoint amount2 = (MyFixedPoint)Math.Min(amount, 9999); inventory.AddItems(amount2, (MyObjectBuilder_PhysicalObject)MyObjectBuilderSerializer.CreateNewObject(item)); }
public void OrganizeInventory(List <IMyCargoContainer> primaryStorage) { List <IMyInventory> inventories = GetInventories(); string componentStorageName = "Component Storage"; string oreIngotStorageName = "Ore and Ingot Storage"; string garbageStorageName = "Garbage Storage"; string gearStorageName = "Gear Storage"; IMyCargoContainer component = (IMyCargoContainer)GridTerminalSystem.GetBlockWithName(componentStorageName); IMyCargoContainer ironOre = (IMyCargoContainer)GridTerminalSystem.GetBlockWithName(oreIngotStorageName); IMyCargoContainer garbage = (IMyCargoContainer)GridTerminalSystem.GetBlockWithName(garbageStorageName); IMyCargoContainer gear = (IMyCargoContainer)GridTerminalSystem.GetBlockWithName(gearStorageName); if (component == null & ironOre == null) { primaryStorage[0].CustomName = componentStorageName; primaryStorage[1].CustomName = oreIngotStorageName; component = (IMyCargoContainer)GridTerminalSystem.GetBlockWithName(componentStorageName); ironOre = (IMyCargoContainer)GridTerminalSystem.GetBlockWithName(oreIngotStorageName); } else if (component == null) { primaryStorage[0].CustomName = componentStorageName; component = (IMyCargoContainer)GridTerminalSystem.GetBlockWithName(componentStorageName); } else if (ironOre == null) { primaryStorage[1].CustomName = oreIngotStorageName; ironOre = (IMyCargoContainer)GridTerminalSystem.GetBlockWithName(oreIngotStorageName); } for (int y = 0; y < inventories.Count; y++) { if (inventories[y].GetItems().Count > 0) { List <IMyInventoryItem> items = inventories[y].GetItems(); for (int x = 0; x < items.Count; x++) { Echo(inventories[y].CurrentMass.ToString()); IMyInventoryItem item; item = items[x]; inventories[y].TransferItemTo(component.GetInventory(), x, null, true, item.Amount); } } } }
public Program() { _PanelTextSurface = Me.GetSurface(0); _PanelTextSurface.ContentType = VRage.Game.GUI.TextPanel.ContentType.TEXT_AND_IMAGE; _PanelTextSurface.FontSize = 2; _PanelTextSurface.Alignment = VRage.Game.GUI.TextPanel.TextAlignment.CENTER; Runtime.UpdateFrequency = UpdateFrequency.Update1; _LCD = GridTerminalSystem.GetBlockWithName("cplcd") as IMyTextSurface; _TextCargo = GridTerminalSystem.GetBlockWithName("samme1") as IMyCargoContainer; _TextLength = _TextCargo.CustomData.Length; _LCD.WriteText(""); }
public static bool isConnectedToCargo(IMyCargoContainer container, IMyTerminalBlock block) { if (container.InventoryCount == 0) { return(false); } IMyInventory inventory = container.GetInventory(0); if (block.InventoryCount == 0) { return(true); } return(block.GetInventory(0).CanTransferItemTo(inventory, ICE_ITEM)); }
/// <summary> /// Automaticka kontrola rafinerii /// </summary> /// <returns>Cargo</returns> public Cargo EnableSorter() { // potrebne bloky Thrower = Instance.GetListByName <IMyShipConnector>("_Thrower", true).First(); Sorter = Instance.GetListByName <IMyCargoContainer>("_Sorter", true); Component = Instance.GetListByName <IMyCargoContainer>("_Component", true).First(); Ingot = Instance.GetListByName <IMyCargoContainer>("_Ingot", true).First(); Ore = Instance.GetListByName <IMyCargoContainer>("_Ore", true).First(); Ice = Instance.GetListByName <IMyCargoContainer>("_Ice", true).First(); // aktivace vyhazovace Thrower.ThrowOut = true; // vycucnuti zasob z konektoru, rafinerii a monteru foreach (KeyValuePair <string, IMyTerminalBlock> block in Instance.GetAll()) { // konektory if (block.Value is IMyShipConnector && !block.Key.Contains("_Thrower")) { TransferItems(block.Value.GetInventory(0)); } // vrtaky if (block.Value is IMyShipDrill) { TransferItems(block.Value.GetInventory(0)); } // rafinerie a pece if (block.Value is IMyRefinery) { TransferItems((block.Value as IMyRefinery).OutputInventory); //TransferItems((block.Value as IMyRefinery).InputInventory, true); } // monteri if (block.Value is IMyAssembler) { TransferItems((block.Value as IMyAssembler).OutputInventory); } } // serazovaci sklad foreach (IMyCargoContainer block in Sorter) { TransferItems(block.GetInventory(0)); } // presortovani kontejneru TransferItems(Component.GetInventory(0)); TransferItems(Ore.GetInventory(0)); TransferItems(Ingot.GetInventory(0)); // vraceni return(this); }
public Program() { Runtime.UpdateFrequency = UpdateFrequency.Update10; Sorter = GridTerminalSystem.GetBlockWithName("Sorter") as IMyConveyorSorter; SAContainer = GridTerminalSystem.GetBlockWithName("Sorter A") as IMyCargoContainer; SBContainer = GridTerminalSystem.GetBlockWithName("Sorter B") as IMyCargoContainer; PBAContainer = GridTerminalSystem.GetBlockWithName("PB A") as IMyCargoContainer; PBBContainer = GridTerminalSystem.GetBlockWithName("PB B") as IMyCargoContainer; SALCD = GridTerminalSystem.GetBlockWithName("Sorter A LCD") as IMyTextPanel; SBLCD = GridTerminalSystem.GetBlockWithName("Sorter B LCD") as IMyTextPanel; PBALCD = GridTerminalSystem.GetBlockWithName("PB A LCD") as IMyTextPanel; PBBLCD = GridTerminalSystem.GetBlockWithName("PB B LCD") as IMyTextPanel; }
public Program() { _PanelTextSurface = Me.GetSurface(0); _PanelTextSurface.ContentType = VRage.Game.GUI.TextPanel.ContentType.TEXT_AND_IMAGE; _PanelTextSurface.FontSize = 2; _PanelTextSurface.Alignment = VRage.Game.GUI.TextPanel.TextAlignment.CENTER; Runtime.UpdateFrequency = UpdateFrequency.Update100; _CargoInterface = GridTerminalSystem.GetBlockWithName("Cargo Interface") as IMyCargoContainer; _SorterOut = GridTerminalSystem.GetBlockWithName("Sorter Interface Out") as IMyConveyorSorter; _SorterIn = GridTerminalSystem.GetBlockWithName("Sorter Interface In") as IMyConveyorSorter; _SorterIn.Enabled = true; _SorterOut.Enabled = false; _Flush = false; }
public bool SplitContainerContents(IMyCargoContainer container) { var inventory = ((Sandbox.ModAPI.Interfaces.IMyInventoryOwner)container).GetInventory(0); var items = inventory.GetItems(); // NB We only check the first item var item = items.Count > 0 ? items[0] : null; var amount = item != null ? (float)item.Amount : 0.0f; if (amount >= StackSize * 2.0f) { // Move to new stack VRage.MyFixedPoint newStackAmount = (VRage.MyFixedPoint)StackSize; inventory.TransferItemTo(inventory, 0, targetItemIndex: items.Count, stackIfPossible: false, amount: newStackAmount); return true; } return false; }