Posted 02 August 2013 - 12:05 AM
Hi, I'm working on a bit of code that has my turtle place down a block and then signal another device using redstone to deal with it, which will break the block. It's intended to repeat this process until it runs out of blocks in its inventory, at which point it should block and wait until its inventory has received more blocks. I'm using os.pullEvent("turtle_inventory"), but changing the turtles inventory, whether by hand or by placing items into it with pipes or golems, doesn't wake up the turtle and cause it to continue. Here's what I've got:
If I use os.pullEvent("redstone"), it will properly wake on a redstone signal, but for some reason this event type isn't working correctly. Have I discovered a bug, or am I using the pullEvent function incorrectly?
Thank you very much for any help!
Edit: I'm running CC 1.53 on MC 1.5.2.
function selectFirstItem()
for i = 1, 16 do
if turtle.getItemCount(i) ~= 0 then
turtle.select(i)
return true
end
end
return false
end
local numProcessed = 0
while(true) do
if (selectFirstItem()) then
if(not turtle.detect()) then
turtle.place()
os.sleep(0.5)
redstone.setOutput("bottom", true)
os.sleep(0.5)
redstone.setOutput("bottom", false)
numProcessed = numProcessed + 1
end
os.sleep(5)
else
print("Process cycle complete - " .. numProcessed .. " ores processed.")
numProcessed = 0
print("Shutting down until I have more work.")
os.pullEvent("turtle_inventory")
print("I am awake! Begining ore processing procedure!")
end
end
If I use os.pullEvent("redstone"), it will properly wake on a redstone signal, but for some reason this event type isn't working correctly. Have I discovered a bug, or am I using the pullEvent function incorrectly?
Thank you very much for any help!
Edit: I'm running CC 1.53 on MC 1.5.2.