Advertisement
einsteinmaster96

farm.lua

Jan 4th, 2025 (edited)
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.27 KB | Gaming | 0 0
  1. line_x = {-3,-1,1,3}
  2. line_y = 1
  3. line_len = 8
  4.  
  5. water_pos_x = { -2, 2 }
  6.  
  7. require("movement")
  8.  
  9.  
  10. function farm_line(x)
  11.     for y=line_y,(line_y + line_len) do
  12.         move_to(x,y)
  13.         success, data = turtle.inspectDown()
  14.         if not success then
  15.             print("not found")
  16.             turtle.digDown()
  17.             turtle.placeDown()
  18.         else
  19.             print("found state "..data["state"]["age"])
  20.             if data["state"]["age"] == 7 then
  21.                 turtle.digDown()
  22.                 turtle.suckDown()
  23.                 turtle.placeDown()
  24.             end
  25.         end
  26.     end
  27. end
  28.  
  29. function suck_items(x)
  30.     move_to(x, line_y)
  31.     turtle.down()
  32.     turtle.suckDown()
  33.     turtle.up()
  34. end
  35.  
  36. function farm()
  37.  
  38.     turtle.select(1)
  39.  
  40.     for k,line_x in pairs(line_x) do
  41.         print("farm line "..line_x)
  42.         farm_line(line_x)
  43.     end
  44.  
  45.     for k,water_x in pairs(water_pos_x) do
  46.         print("suck items "..water_x)
  47.         suck_items(water_x)
  48.     end
  49.  
  50.     print("return home")
  51.  
  52.     move_to(0,0)
  53.  
  54.     print("remove all items")
  55.     for i=2,16 do
  56.         turtle.select(i)
  57.         turtle.dropDown()
  58.     end
  59.  
  60. end
  61.  
  62. if pcall(debug.getlocal, 4, 1) then
  63.     print("in package")
  64. else
  65.     print("in main script")
  66.     farm()
  67. end
  68.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement