This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
subzero22's profile picture

possible to do os.pullevent with metadata?

Started by subzero22, 01 March 2016 - 11:02 PM
subzero22 #1
Posted 02 March 2016 - 12:02 AM
I'm making a farming program and I can't figure out how to get metadata to work with pullevent.

local success, t = turtle.inspectDown() it will return the name of the plant and the metadata for how grown it is. But I'm trying to get os.pullEvent to check and wait for t.metadata to equal 7 then start the farming program.

Sorry if I'm confusing just not sure how to explain it fully but it would be like wait for wheat to grow once metadata hits 7 turtle starts farming it's strips then returns and waits again.
HPWebcamAble #2
Posted 02 March 2016 - 12:34 AM
You never actually said so, but I assume you want to the computer to wait for the plant to grow.

You'd use a loop and sleep

while true do

  local success,t = turtle.inspectDown()

  if t.metaData == 7 then --# This is probably not correct, I assume you know what index the plant's growth is stored in
    break
  end

  sleep(5)

end

It continuously loops, checking the block below it each time.
When the metadata is 7, it breaks the loop
If the loop hasn't been broken at that point (meaning the plant isn't ready), it simply sleeps for 5 seconds.
subzero22 #3
Posted 02 March 2016 - 06:13 PM
lol thanks never thought to go that rout for it. I got it to check if fully grown when harvesting should have put a if / sleep at the beginning before the main program runs. Thanks