Posted 17 April 2017 - 12:04 PM
Auto Item Smelter (Basic, UNDER 50 LINES)
This started as a 250+ line program I made to smelt items from one chest into another, but then I started getting rid of alot of the functionality to drastically reduce it's line count and efficiency, it's now under 50 lines and has support for a variable amount of furnaces and different fuels.
If one furnace is done before the other however it cannot re-task it until all the furnaces are done which I cannot see an easy way to do without timers and tables containing how much time each one has left etc…
Pastebin: https://pastebin.com/x7FVCisU
Code:
local furnaces = 8 –the amount of furnaces the chef has (MAX 8)
local amounts = {}
function selectNext()
for i = 1, 16 do
if turtle.getItemCount(i) ~= 0 then
turtle.select(i)
return true
end
end
return false
end
while turtle.suck() do
for i = 2, furnaces do
table.insert(amounts, 0)
if not turtle.suck() then break end
end
for k, v in pairs(amounts) do
turtle.back()
amounts[k] = turtle.getItemCount()
turtle.dropDown()
end
while turtle.forward() do end
turtle.select(1)
turtle.down()
for k, v in pairs(amounts) do
turtle.suck(math.ceil(v/8))
end
turtle.down()
local biggestStack = 0
for k, v in pairs(amounts) do
if v > biggestStack then
biggestStack = v
end
turtle.back()
turtle.dropUp(math.ceil(v/8))
end
sleep(biggestStack*10)
for k, v in pairs(amounts) do
turtle.suckUp()
turtle.forward()
end
while selectNext() do turtle.drop() end
turtle.up()
turtle.up()
turtle.select(1)
end
Usage:
Move the turtle up one space and run the program AFTER putting all the fuel + ore into the middle and top chest respectively. (SHOWN BELOW)
This started as a 250+ line program I made to smelt items from one chest into another, but then I started getting rid of alot of the functionality to drastically reduce it's line count and efficiency, it's now under 50 lines and has support for a variable amount of furnaces and different fuels.
If one furnace is done before the other however it cannot re-task it until all the furnaces are done which I cannot see an easy way to do without timers and tables containing how much time each one has left etc…
Pastebin: https://pastebin.com/x7FVCisU
Code:
Spoiler
local efficiency = 8 –the amount of items each fuel item can smeltlocal furnaces = 8 –the amount of furnaces the chef has (MAX 8)
local amounts = {}
function selectNext()
for i = 1, 16 do
if turtle.getItemCount(i) ~= 0 then
turtle.select(i)
return true
end
end
return false
end
while turtle.suck() do
for i = 2, furnaces do
table.insert(amounts, 0)
if not turtle.suck() then break end
end
for k, v in pairs(amounts) do
turtle.back()
amounts[k] = turtle.getItemCount()
turtle.dropDown()
end
while turtle.forward() do end
turtle.select(1)
turtle.down()
for k, v in pairs(amounts) do
turtle.suck(math.ceil(v/8))
end
turtle.down()
local biggestStack = 0
for k, v in pairs(amounts) do
if v > biggestStack then
biggestStack = v
end
turtle.back()
turtle.dropUp(math.ceil(v/8))
end
sleep(biggestStack*10)
for k, v in pairs(amounts) do
turtle.suckUp()
turtle.forward()
end
while selectNext() do turtle.drop() end
turtle.up()
turtle.up()
turtle.select(1)
end
Usage:
Spoiler
Put three chests above eachother with the turtle facing the middle one, the put up to 8 furnaces behind the turtle.Move the turtle up one space and run the program AFTER putting all the fuel + ore into the middle and top chest respectively. (SHOWN BELOW)