Advertisement
Renjestoo

Autosmelter (with autobuild)

Sep 2nd, 2018
319
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.80 KB | None | 0 0
  1. efficiency = 8 --the amount of items each fuel item can smelt
  2. furnaces = 0 --the amount of furnaces the chef has (MAX 8)
  3. amounts = {}
  4. coal = 0
  5. fuel = 1
  6. timer = 10 -- the amount of time 1 item smelts
  7. cooktime = timer*efficiency
  8. data = turtle.getItemDetail()
  9.  
  10.  
  11. for i, side in ipairs(rs.getSides()) do --#Loop for each side on the computer that redstone can be used, these can also be used by modems.
  12. if peripheral.getType(side) == 'modem' then --#Did we find a modem... Or some other peripheral?
  13.   print('Found Modem On Side '..side.."!")
  14.   rednet.open(side)
  15.   wireless = peripheral.wrap(side)
  16.   break --#Opened modem, dont open any others.
  17. end
  18. end
  19.  
  20. function sendMessage(destination, message, protocol)
  21.     if destination and message then
  22.         rednet.send(destination, message, protocol)
  23.     end
  24. end
  25.  
  26.  
  27. function collectCoal()
  28.     turtle.select(1)
  29.     turtle.up()
  30.     turtle.suck(coal)
  31. end
  32.  
  33. function collectOre()
  34.     turtle.up()
  35.     for i = 2, furnaces+1 do
  36.         turtle.select(i)
  37.         turtle.suck(efficiency)
  38.     end
  39. end
  40.  
  41. function smelt()
  42.     for i = 2, furnaces+1 do
  43.         turtle.back()
  44.         turtle.select(i)
  45.         turtle.dropDown(efficiency)
  46.     end
  47.     term.clear()
  48.     term.setCursorPos(1,1)
  49.     sendMessage(3, "Going to add fuel to the furnaces...")
  50.     for i = 1, furnaces do
  51.         turtle.forward()
  52.     end
  53.     turtle.down()
  54.     turtle.down()
  55.     turtle.select(1)
  56.     for i = 2, furnaces+1 do
  57.         turtle.back()
  58.         turtle.dropUp(fuel)
  59.     end
  60.     for i = cooktime, 0, -1 do
  61.         term.clear()
  62.         term.setCursorPos(1,1)
  63.         sendMessage(3, "Time left to collect smeltables: " .. i)
  64.         sleep(1)
  65.     end
  66.     term.clear()
  67.     term.setCursorPos(1,1)
  68.     sendMessage(3, "Collecting all the smeltables")
  69.     for i = 1, furnaces do
  70.         turtle.suckUp()
  71.         turtle.forward()
  72.     end
  73.     turtle.forward()
  74.     term.clear()
  75.     term.setCursorPos(1,1)
  76.     sendMessage(3, "Putting all items in the Chest")
  77.     for i = 1,16 do
  78.         turtle.select(i)
  79.         turtle.drop()
  80.     end
  81. end
  82.  
  83.  
  84. term.clear()
  85. term.setCursorPos(1,1)
  86. sendMessage(3, "This is an auto ore smelter. If you didn't setup anything, you can follow the next steps to let the turtle build it for you.")
  87. sleep(4)
  88. term.setCursorPos(1,3)
  89. sendMessage(3, "Place up to 15 furnaces into slot 1")
  90. sleep(3)
  91. term.setCursorPos(1,4)
  92. sendMessage(3, "Place 6 chests into slot 2")
  93. sleep(3)    term.setCursorPos(1,6)
  94. sendMessage(3, "Press 1 to build,  Press 2 to start immediately.")
  95. local event, key = os.pullEvent("key")
  96. if event == "1" then
  97.     turtle.select(1)
  98.     if turtle.getItemCount( turtle.getSelectedSlot() ) < 1 then
  99.    
  100.     else
  101.         turtle.select(1)
  102.         local data = turtle.getItemDetail()
  103.         furnaces = data.count
  104.         coal = data.count
  105.         sendMessage(3, "Building smelter structure")
  106.         for i = 1, furnaces do
  107.             turtle.back(i)
  108.             turtle.placeUp(1)
  109.         end
  110.         for i = 1, furnaces do
  111.             turtle.forward()
  112.         end
  113.         turtle.select(2)
  114.         turtle.place()
  115.         turtle.up()
  116.         turtle.place()
  117.         turtle.up()
  118.         turtle.place()
  119.         turtle.turnRight()
  120.         turtle.forward()
  121.         turtle.turnLeft()
  122.         turtle.place()
  123.         turtle.down()
  124.         turtle.place()
  125.         turtle.down()
  126.         turtle.place()
  127.         turtle.turnLeft()
  128.         turtle.forward()
  129.         turtle.turnRight()
  130.     end
  131. else
  132.     turtle.back()
  133.     while turtle.inspectUp() ~= false do
  134.         furnaces = furnaces+1
  135.         coal = coal+1
  136.         turtle.back()
  137.         sendMessage(3, "Total of furnaces in this build: " .. furnaces)
  138.     end
  139.     for i = 1, furnaces+1 do
  140.         turtle.forward()
  141.     end
  142. end
  143.  
  144. while true do
  145.     term.clear()
  146.     term.setCursorPos(1,1)
  147.     sendMessage(3, "Collecting Coal...")
  148.     collectCoal()
  149.     sleep(1)
  150.     term.clear()
  151.     term.setCursorPos(1,1)
  152.     sendMessage(3, "Collecting Ores to smelt...")
  153.     collectOre()
  154.     sleep(1)
  155.     term.clear()
  156.     term.setCursorPos(1,1)
  157.     sendMessage(3, "Going off to smelt all the Ores...")
  158.     smelt()
  159.     term.clear()
  160.     term.setCursorPos(1,1)
  161.     sendMessage(3, "All smelted ores are delivered")
  162.     sleep(0,2)
  163.     sendMessage(3, "Preparing to smelt next batch of Ores.....")
  164.     sleep(5)
  165. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement