Advertisement
Meridius_IX

Assembler Queue Rotator

Oct 16th, 2017
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.30 KB | None | 0 0
  1.  
  2. //Each time this script is run, it will rotate the assembler production queue to the next item. Simply add "RotateQueue" to the name of any assembler you want to use this on.
  3.  
  4. string assemblerTag = "RotateQueue"; //This is the tag that is applied to the Assembler Custom Name to have it use the queue rotation.
  5.  
  6. void Main(){
  7.  
  8.     List<IMyProductionBlock> assemblers = new List<IMyProductionBlock>(); //Create Empty List For Assemblers
  9.     GridTerminalSystem.GetBlocksOfType<IMyProductionBlock>(assemblers); //Populate List With Assemblers
  10.    
  11.     //Loop through list of assemblers
  12.     foreach(var assembler in assemblers){
  13.        
  14.         //Check if each assembler contains the Assembler Tag
  15.         if(assembler.CustomName.Contains(assemblerTag)){
  16.            
  17.             //Get the production queue of each assembler.
  18.             List<MyProductionItem> assemblerQueue = new List<MyProductionItem>();
  19.             assembler.GetQueue(assemblerQueue);
  20.            
  21.             //Ensure the prodcution queue is not empty.
  22.             if(assemblerQueue.Count == 0){
  23.                
  24.                 //Queue is empty, move to next assembler.
  25.                 continue;
  26.                
  27.             }
  28.            
  29.             var firstItem = assemblerQueue[0]; //Get the first item in the assembler production queue.
  30.             assembler.MoveQueueItemRequest(firstItem.ItemId, assemblerQueue.Count - 1); //Move the first item in queue to the back of the queue.
  31.            
  32.         }
  33.        
  34.     }
  35.  
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement