Advertisement
melzneni

SetLabel

Sep 13th, 2023 (edited)
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.83 KB | None | 0 0
  1. #import: AvJ5pXCS;
  2. #import: AAMw1hB3;
  3.  
  4. clearGrid: {
  5. #{
  6. for (i=0;i<16;i++){
  7. while(getItemCount(i)!=0){
  8. sleep(0.1);
  9. };
  10. };
  11. };
  12. };
  13.  
  14. craftDialog:{
  15. shellExecute("label","set","no query");
  16. clearTerminal();
  17. clearGrid();
  18. shellExecute("label","set","*");
  19. while (true){
  20. #{
  21. clearTerminal();
  22. print("Type '#' to exit");
  23. print("Type 'a' for advanced mode");
  24. choice = input("Press Enter to craft");
  25. };
  26. if (choice=="#"){
  27. break;
  28. } else if (choice==""){
  29. craft();
  30. } else if (choice=="a"){
  31. advancedCrafting();
  32. break;
  33. };
  34. };
  35. shellExecute("label","set","no query");
  36. };
  37.  
  38. advancedCrafting:{
  39. print("Please prepare recipe");
  40. input("");
  41. config = {};
  42. itemCounts = {};
  43. #{
  44. for (i=0;i<16;i++) {
  45. name = getItemName(i);
  46. if (name==null){continue;};
  47. config[i] = name;
  48. count = itemCounts[name];
  49. if (count==null){
  50. count=0;
  51. };
  52. count = count + getItemCount(i);
  53. itemCounts[name] = count;
  54. };
  55.  
  56. storageCounts = getStorageCounts(itemCounts);
  57.  
  58. maxCraftingCount = null;
  59. limitingItem=null;
  60. limitingCount=null;
  61. itemKeys = itemCounts.keys();
  62. for(i=0;i<itemKeys.length;i++){
  63. key = itemKeys[i];
  64. requested = itemCounts[key];
  65. available = storageCounts[key];
  66. craftable = abs(available / requested);
  67. if (maxCraftingCount == null || craftable < maxCraftingCount){
  68. maxCraftingCount = craftable;
  69. limitingItem = key;
  70. limitingCount = available;
  71. }
  72. };
  73. print("Possible crafting cycles: " + maxCraftingCount);
  74. };
  75.  
  76. cyclesToPerform = input("Cycles");
  77. cycles64 = abs(cyclesToPerform / 64);
  78. cyclesLess64 = cyclesToPerform % 64;
  79.  
  80. for (i=0; i < cycles64; i++){
  81. clearGrid();
  82. pullCraftingItems(config, 64);
  83. sleep(30);
  84. craft();
  85. };
  86. clearGrid();
  87. pullCraftingItems(config, cyclesLess64);
  88. craft();
  89. };
  90.  
  91. main: {
  92. last = null;
  93. while(true){
  94. # {
  95. clearTerminal();
  96. print("Type '#' to craft, '*' to count");
  97. searchString = input("");
  98. };
  99. if (searchString==""){
  100. searchString="no query";
  101. } else if (searchString=="#"){
  102. craftDialog();
  103. continue;
  104. } else if (searchString=="*"){
  105. printItemCounts();
  106. continue;
  107. };
  108. shellExecute("label","set",searchString);
  109. last=searchString;
  110. }
  111. };
  112.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement