Advertisement
EpicestGamer

Super Sorter - An auto-repairer and item broadcaster

Jul 16th, 2019
635
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 6.55 KB | None | 0 0
  1. --[[ SUPER SORTER ]]--
  2.  
  3. -- Super Sorter doesn't do much sorting currently.
  4. -- It's current functions are
  5. -- Automatically repairing items that come out of mob grinders
  6. -- Broadcasting fully repaired / miscellaneous items for base monitoring purposes
  7.  
  8. -- It's not plug and play, there will be configuration, however it should work in other people's set ups
  9. -- I just don't feel like documenting the configuration process so...
  10.  
  11. --[[ CONFIGURATION ]]--
  12. -- TODO: better document configuration
  13.  
  14. local broadcastChannel = "mobmon-eg"
  15.  
  16. local repairChest = "back"
  17. local repairPos = "north" -- turtle relative to the repair chest
  18.  
  19. local repairables = {
  20.     "minecraft:iron_sword",
  21.     "minecraft:iron_pickaxe",
  22.     "minecraft:iron_axe",
  23.     "minecraft:iron_shovel",
  24.     "minecraft:iron_helmet",
  25.     "minecraft:iron_chestplate",
  26.     "minecraft:iron_leggings",
  27.     "minecraft:iron_boots",
  28.     "minecraft:diamond_sword",
  29.     "minecraft:diamond_pickaxe",
  30.     "minecraft:diamond_axe",
  31.     "minecraft:diamond_shovel",
  32.     "minecraft:diamond_helmet",
  33.     "minecraft:diamond_chestplate",
  34.     "minecraft:diamond_leggings",
  35.     "minecraft:diamond_boots",
  36.     "minecraft:stone_sword",
  37.     "minecraft:stone_pickaxe",
  38.     "minecraft:stone_axe",
  39.     "minecraft:stone_shovel",
  40.     "minecraft:chainmail_helmet",
  41.     "minecraft:chainmail_chestplate",
  42.     "minecraft:chainmail_leggings",
  43.     "minecraft:chainmail_boots",
  44.     "minecraft:wooden_sword",
  45.     "minecraft:wooden_pickaxe",
  46.     "minecraft:wooden_axe",
  47.     "minecraft:wooden_shovel",
  48.     "minecraft:leather_helmet",
  49.     "minecraft:leather_chestplate",
  50.     "minecraft:leather_leggings",
  51.     "minecraft:leather_boots",
  52.     "minecraft:golden_sword",
  53.     "minecraft:golden_pickaxe",
  54.     "minecraft:golden_axe",
  55.     "minecraft:golden_shovel",
  56.     "minecraft:golden_helmet",
  57.     "minecraft:golden_chestplate",
  58.     "minecraft:golden_leggings",
  59.     "minecraft:golden_boots",
  60.     "minecraft:bow",
  61.     "minecraft:shield",
  62.     "botania:manaweaveboots",
  63.     "botania:manaweavelegs",
  64.     "botania:manaweavechest",
  65.     "botania:manaweavehelm",
  66.     "botania:manasteelboots",
  67.     "botania:manasteellegs",
  68.     "botania:manasteelchest",
  69.     "botania:manasteelhelm",
  70.     "botania:elementiumboots",
  71.     "botania:elementiumlegs",
  72.     "botania:elementiumchest",
  73.     "botania:elementiumhelm",
  74.     "twilightforest:fiery_boots",
  75.     "twilightforest:fiery_leggings",
  76.     "twilightforest:fiery_chestplate",
  77.     "twilightforest:fiery_helmet",
  78.     "twilightforest:knightmetal_boots",
  79.     "twilightforest:knightmetal_leggings",
  80.     "twilightforest:knightmetal_chestplate",
  81.     "twilightforest:knightmetal_helmet",
  82.     "twilightforest:ironwood_boots",
  83.     "twilightforest:ironwood_leggings",
  84.     "twilightforest:ironwood_chestplate",
  85.     "twilightforest:ironwood_helmet",
  86.     "twilightforest:steeleaf_boots",
  87.     "twilightforest:steeleaf_leggings",
  88.     "twilightforest:steeleaf_chestplate",
  89.     "twilightforest:steeleaf_helmet",
  90.     "mysticalagriculture:prudentium_boots",
  91.     "mysticalagriculture:prudentium_leggings",
  92.     "mysticalagriculture:prudentium_chestplate",
  93.     "mysticalagriculture:prudentium_helmet",
  94.     "mysticalagriculture:inferium_boots",
  95.     "mysticalagriculture:inferium_leggings",
  96.     "mysticalagriculture:inferium_chestplate",
  97.     "mysticalagriculture:inferium_helmet",
  98.     "mysticalagriculture:intermedium_boots",
  99.     "mysticalagriculture:intermedium_leggings",
  100.     "mysticalagriculture:intermedium_chestplate",
  101.     "mysticalagriculture:intermedium_helmet",
  102.     "mysticalagriculture:superium_boots",
  103.     "mysticalagriculture:superium_leggings",
  104.     "mysticalagriculture:superium_chestplate",
  105.     "mysticalagriculture:superium_helmet",
  106.     "nuclearcraft:boots_boron",
  107.     "nuclearcraft:legs_boron",
  108.     "nuclearcraft:chest_boron",
  109.     "nuclearcraft:helm_boron",
  110.     "nuclearcraft:boots_tough",
  111.     "nuclearcraft:legs_tough",
  112.     "nuclearcraft:chest_tough",
  113.     "nuclearcraft:helm_tough",
  114.     "psi:psimetal_exosuit_boots",
  115.     "psi:psimetal_exosuit_leggings",
  116.     "psi:psimetal_exosuit_chestplate",
  117.     "psi:psimetal_exosuit_helmet",
  118.     "immersiveengineering:faraday_suit_feet",
  119.     "immersiveengineering:faraday_suit_legs",
  120.     "immersiveengineering:faraday_suit_chest",
  121.     "immersiveengineering:faraday_suit_head",
  122.     "botania:terrasteelboots",
  123.     "botania:terrasteellegs",
  124.     "botania:terrasteelchest",
  125.     "botania:terrasteelhelm",
  126.     "thermalfoundation:tool.sword_invar",
  127.     "botania:elementiumsword",
  128.     "nuclearcraft:boots_hard_carbon",
  129.     "nuclearcraft:legs_hard_carbon",
  130.     "nuclearcraft:chest_hard_carbon",
  131.     "nuclearcraft:helm_hard_carbon",
  132.     "mysticalagriculture:intermedium_sword"
  133. }
  134.  
  135. local meltables = {
  136.     "minecraft:iron_sword",
  137.     "minecraft:iron_pickaxe",
  138.     "minecraft:iron_axe",
  139.     "minecraft:iron_shovel",
  140.     "minecraft:iron_shovel",
  141.     "minecraft:iron_helmet",
  142.     "minecraft:iron_chestplate",
  143.     "minecraft:iron_leggings",
  144.     "minecraft:iron_boots",
  145.     "minecraft:gold_sword",
  146.     "minecraft:golden_pickaxe",
  147.     "minecraft:golden_axe",
  148.     "minecraft:golden_shovel",
  149.     "minecraft:golden_helmet",
  150.     "minecraft:golden_chestplate",
  151.     "minecraft:golden_leggings",
  152.     "minecraft:golden_boots"
  153. }
  154.  
  155. --[[ PROGRAM ]]--
  156.  
  157. rednet.open("left")
  158.  
  159. function table.contains(array, element)
  160.   for key, value in pairs(array) do
  161.     if value == element then
  162.       return key
  163.     end
  164.   end
  165.   return nil
  166. end
  167.  
  168. -- Seems to fix a problem for some reason, perhaps refreshing peripherals
  169. peripheral.getNames()
  170. local repair = peripheral.wrap(repairChest)
  171.  
  172. -- Main program
  173. print("Starting super sorter...")
  174.  
  175. while true do
  176.     turtle.select(1)
  177.     local status = 0;
  178.     -- Grab an item from input
  179.     while not turtle.suck() do -- nothing
  180.     end
  181.    
  182.     local itemData = turtle.getItemDetail()
  183.     print ("Found "..itemData.name)
  184.     local containment = table.contains(repairables, itemData.name)
  185.     if containment then
  186.         if itemData.damage > 0 then
  187.             -- Repair
  188.             local repairable = repair.pushItems(repairPos, containment)
  189.             if repairable == 1 then
  190.                 print("Repairing...")
  191.                 turtle.craft()
  192.                
  193.                 itemData = turtle.getItemDetail()
  194.             end
  195.         end
  196.         if itemData.damage == 0 then
  197.             if table.contains(meltables, itemData.name) then
  198.                   -- Melt
  199.                   turtle.dropUp()
  200.                   print("Melting.")
  201.                   status = 2
  202.             else
  203.                 -- Put in output
  204.                 turtle.dropDown()
  205.                 print("Saving for later.")
  206.                 status = 1
  207.             end
  208.         else
  209.             -- Put aside for repairing
  210.             repair.pullItems(repairPos, 1, 1, containment)
  211.             print("Saving for later repairs.")
  212.             status = 0
  213.         end
  214.     else
  215.         -- Put in output chest
  216.         turtle.dropDown()
  217.         print("Saving for later")
  218.     end
  219.     itemData.status = status
  220.     rednet.broadcast(itemData, broadcastChannel)
  221.     print("Processed "..itemData.name)
  222. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement