Advertisement
nagoL2015

Smelter

Mar 14th, 2018
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.28 KB | None | 0 0
  1. local coal = "minecraft:chest_269"
  2. local input = "minecraft:chest_270"
  3. local output = "minecraft:chest_271"
  4. local self = "turtle_157"
  5. local furnaces = {}
  6. local periphs = {}
  7.  
  8. for k, v in pairs(peripheral.getNames()) do
  9.   periphs[v] = peripheral.wrap(v)
  10. end
  11.  
  12. for k,v in pairs(periphs) do
  13.     if k:find("furnace") then
  14.         furnaces[#furnaces + 1] = k
  15.     end
  16. end
  17.  
  18. print("loading coal")
  19. for k,v in pairs(periphs[coal].list()) do
  20.     periphs[coal].pushItems(self, k, v.count, 1)
  21.     for i = 1, v.count do
  22.         periphs[furnaces[math.random(1, #furnaces)]].pullItems(self, 1, 1, 2)
  23.     end
  24.  sleep(0.1)
  25.  periphs[coal].pullItems(self, 1, 64)
  26. end
  27.  
  28. print("load input")
  29. for k,v in pairs(periphs[input].list()) do
  30.     local times = math.floor(v.count / 7)
  31.     if times > 0 then
  32.         periphs[input].pushItems(self, k, times * 7, 1)
  33.         for i = 1, times do
  34.             periphs[furnaces[math.random(1, #furnaces)]].pullItems(self, 1, 7, 1)
  35.             sleep(0.1)
  36.         end
  37.         periphs[input].pullItems(self, 1, 64)
  38.     end
  39. end
  40.  
  41. print("collecting output")
  42. for i = 1, #furnaces do
  43.     local inputper = periphs[furnaces[i]]
  44.     local outputper = periphs[output]
  45.     inputper.pushItems(self, 3, 64, 1)
  46.     outputper.pullItems(self, 1, 64)
  47.     sleep(0.1)
  48. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement