Advertisement
Guest User

startup

a guest
Apr 30th, 2015
281
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.91 KB | None | 0 0
  1. local fullyGrown = 7
  2.  
  3. local harvestedFile = "harvested"
  4. local harvested = {}
  5. while true do
  6.   local success,data = turtle.inspect()
  7.   if success then
  8.     term.clear()
  9.     term.setCursorPos(1,1)
  10.     print("Block Metadata: "..data.metadata)
  11.     if data.metadata == fullyGrown then
  12.       turtle.dig()
  13.       os.sleep(5)
  14.       for i=1,16,1 do
  15.         turtle.select(i)
  16.         turtle.place()
  17.       end
  18.       turtle.select(1)
  19.     end
  20.   else
  21.     os.sleep(5)
  22.     for i=1,16,1 do
  23.       turtle.select(i)
  24.       turtle.place()
  25.     end
  26.     harvested = {}
  27.     local file = fs.open(harvestedFile,"a")
  28.     file.close()
  29.     local file = fs.open(harvestedFile,"r")
  30.     local line = file.readLine()
  31.     repeat
  32.       table.insert(harvested,line)
  33.     until line == nil
  34.     file.close()
  35.     x = harvested[1] + 1
  36.     local file = fs.open(harvestedFile,"w")
  37.     file.writeLine(x)
  38.     file.close()
  39.     print(x)
  40.   end
  41. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement