dadragon84

Ore Smelter

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