Posted 31 December 2013 - 12:33 PM
Hi all,
sorry to ask that, but i cant find my mistake in this simple turtle program i wrote. Somehow the suckUp() method takes 2 stacks instead just one and i cant find the mistake.
So i wanted to ask a Pro :)/>
I post the whole code so you can run it and see if it produces the same strange thing:
sorry to ask that, but i cant find my mistake in this simple turtle program i wrote. Somehow the suckUp() method takes 2 stacks instead just one and i cant find the mistake.
So i wanted to ask a Pro :)/>
I post the whole code so you can run it and see if it produces the same strange thing:
local function CheckSlots()
if (turtle.getItemCount(2) == 0) or (turtle.getItemCount(5) == 0) or (turtle.getItemCount(6) == 0) or (turtle.getItemCount(9) == 0) then
return false
else
--write ("true\n")
return true
end
end
local function ClearSlots()
write("ClearSlots - Running\n")
turtle.select(2)
turtle.dropUp()
turtle.select(5)
turtle.dropUp()
turtle.select(6)
turtle.dropUp()
turtle.select(9)
turtle.dropUp()
end
local function FillSlots()
write("FillSlots - Running\n")
turtle.select(2)
turtle.suckUp()
turtle.select(5)
turtle.suckUp()
turtle.select(6)
turtle.suckUp()
turtle.select(9)
turtle.suckUp()
end
local function FillStack()
write ("FillStack - Running\n")
if turtle.getItemCount(2) == 0 then
write ("Select Slot2\n")
turtle.select(2)
write ("Suck Slot2\n")
sleep(5)
turtle.suckUp()
end
if turtle.getItemCount(5) == 0 then
write ("Select Slot5\n")
turtle.select(5)
write ("Suck Slot5\n")
sleep(5)
turtle.suckUp()
end
if turtle.getItemCount(6) == 0 then
write ("Select Slot6\n")
turtle.select(6)
write ("Suck Slot6\n")
sleep(5)
turtle.suckUp()
end
if turtle.getItemCount(9) == 0 then
write ("Select Slot9\n")
turtle.select(9)
write ("Suck Slot9\n")
sleep(5)
turtle.suckUp()
end
write("FillStack - Finished\n")
end
local function DropResult()
turtle.select(16)
turtle.dropDown()
end
local function SpreadSlots()
write("SpreadSlots - Running\n")
sum = (turtle.getItemCount(9) + turtle.getItemCount(6) + turtle.getItemCount(5) + turtle.getItemCount(2))
result = math.floor((sum/4) + 0.5)
space = ' '
-- write (sum..space..result.."\n")
ClearSlots()
turtle.select(2)
turtle.suckUp()
turtle.dropUp((turtle.getItemCount(2)-result))
turtle.select(5)
turtle.suckUp()
turtle.dropUp((turtle.getItemCount(5)-result))
turtle.select(6)
turtle.suckUp()
turtle.dropUp((turtle.getItemCount(6)-result))
turtle.select(9)
turtle.suckUp()
end
local function CleanInventory()
write("CleanInventory - Running\n")
turtle.select(3)
turtle.dropUp()
turtle.select(7)
turtle.dropUp()
turtle.select(10)
turtle.dropUp()
end
local function Production()
while true do
write("Production Check\n")
sleep(5)
if CheckSlots() == false then
write("CheckSlots - false\n")
FillStack()
if turtle.suckUp() == false then
write("SuckUp - false\n")
SpreadSlots()
end
end
if CheckSlots() == true then
turtle.select(16)
turtle.craft()
DropResult()
end
end
end
-- Hauptprogramm:
ClearSlots()
CleanInventory()
FillSlots()
Production()