One of your biggest friends in cleaning up your code will be the for loop. Site with short explanation here:
http://www.tutorials...ua_for_loop.htmAnother thing will be the modulus operator "%". The useful part about modulus, is you can use it to see if a number can be evenly divided into by another number. Luckily in your program all of the slots you want to avoid using can be divided by 4, which makes it easy to check. You can think of modulus as the remainder if one number was divided by another.
Example of modulus:
2%5 --# this will output 2, because 5 can not go into 2 any evenly
7%5 --# this will also output 2, because after 5 goes into 7 once evenly all that is left is 2
12%5 --# also 2 for same reason as above
--# if you want to see if a number has can be evenly divided
4%2 --# this will equal 0, because 2 goes into 4 evenly
9%3 --# also 0
local slot1 = turtle.getItemDetail(1).name
local slot2 = turtle.getItemDetail(2).name
local slot3 = turtle.getItemDetail(3).name
local slot5 = turtle.getItemDetail(5).name
local slot6 = turtle.getItemDetail(6).name
local slot7 = turtle.getItemDetail(7).name
local slot9 = turtle.getItemDetail(9).name
local slot10 = turtle.getItemDetail(10).name
local slot11 = turtle.getItemDetail(11).name
local A = 4
local C = "minecraft:cobblestone"
function suckCobble()
for i = 1, 11 do --# refer to the link i posted to see what this loop is doing
if i%4 == 0 then -- Checking to see if i can be evenly divided by 4
turtle.select(i)
turtle.suck(A)
end
end
end
function balance()
for i = 1, 11 do
if i%4 == 0 then --# checking to see if i can be equal divided by 4
if turtle.getItemCount(i) ~= A + 1 then
turtle.select(i)
turtle.drop()
turtle.suck(A + 1)
end
end
end
end
while true do
suckCobble()
balance()
turtle.craft(A)
sleep(15)
end
There are a few other things that could be cut down, but they are slightly more complicated. If you want to look them up on your own, the main thing I left out is you could use a table to hold all of those variables that you defined at the beginning.