Advertisement
NickNDS

Sorter Manager

Jan 13th, 2022
458
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.72 KB | None | 0 0
  1. public List<IMyConveyorSorter> sorterList = new List<IMyConveyorSorter>(),
  2. groupedList = new List<IMyConveyorSorter>();
  3. public Program()
  4. {
  5. Runtime.UpdateFrequency = UpdateFrequency.Update10;
  6. }
  7.  
  8. public void Main(string argument, UpdateType updateSource)
  9. {
  10. try
  11. {
  12. if (sorterList.Count == 0)
  13. {
  14. GridTerminalSystem.GetBlocksOfType<IMyConveyorSorter>(sorterList);
  15. }
  16. else if (groupedList.Count == 0)
  17. {
  18. try
  19. {
  20. IMyConveyorSorter currentSorter = sorterList[0];
  21. string name = currentSorter.CustomName;
  22. GridTerminalSystem.GetBlockGroupWithName(name).GetBlocksOfType<IMyConveyorSorter>(groupedList);
  23. }
  24. catch { sorterList.RemoveAt(0); }
  25. }
  26. else
  27. {
  28. IMyConveyorSorter currentSorter = sorterList[0];
  29. MyConveyorSorterMode mode = currentSorter.Mode;
  30. List<MyInventoryItemFilter> filterList = new List<MyInventoryItemFilter>();
  31. currentSorter.GetFilterList(filterList);
  32. int groupCount = groupedList.Count;
  33. for (int reps = 0; reps < groupCount && reps < 10; reps++)
  34. {
  35. try
  36. {
  37. groupedList[0].SetFilter(mode, filterList);
  38. }
  39. catch { }
  40. groupedList.RemoveAt(0);
  41. }
  42. }
  43. }
  44. catch
  45. {
  46. sorterList.Clear();
  47. groupedList.Clear();
  48. }
  49. Echo("Sorter Manager");
  50. Echo("Any Sorter with a group named after it become a controller for that group");
  51. Echo("Sorters in a group named after another sorter will copy the controller");
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement