Posted 24 September 2013 - 01:25 PM
I've been trying to build a program that will automate some aspects of my crafting setup. I'm using Open.Peripheral to detect items in a chest and move them to my Macerator and then my Electric Furnace. However, I'm trying to use While True Do to loop these commands so I don't have to run it each time.
here is my code so far:
There must be something braking in the code that detects Ore that causes the loop to end. I'm just not sure what it is.
here is my code so far:
chest.condense() --Organize the Chest
local slotnum = chest.getSizeInventory() --Use the Max Invantory Size to calculate the Slot number and Loop amount
local macedone = mace.getStackInSlot(1)
local efurndone = efurn.getStackInSlot(1)
while true do
os.startTimer(5)
event = os.pullEvent()
if event == "timer" then
--push completed items out of the mace and efurn--
mace.push("north", 1, 64)
efurn.push("up", 1, 64)
--start looking for ore--
for i=1,slotnum do -- LOOP!
local tableInfo = chest.getStackInSlot(i)
if tableInfo ~= nil then
for key, value in pairs(tableInfo) do
if string.find(value, "Ore") then -- Find Ore
print("Ore Found! Moving to Macerator!")
chest.push("north", i, 64)
else
end
end
else
end
end
else
end
end
There must be something braking in the code that detects Ore that causes the loop to end. I'm just not sure what it is.