skypop

SugarFarmer

Sep 16th, 2016
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.57 KB | None | 0 0
  1. local i
  2. local function crop()
  3.     for i=1,8 do
  4.         if i<=4 then turtle.dig() end
  5.         turtle.suck()
  6.         turtle.suckUp()
  7.         if i<8 then turtle.turnLeft() end
  8.     end
  9. end
  10.  
  11. local function dump()
  12.     for i=1,16 do
  13.         if turtle.getItemCount(i)>0 then
  14.             turtle.select(i)
  15.             turtle.dropDown(64)
  16.         end
  17.     end
  18. end
  19.  
  20. local _f = math.floor
  21. local function strTime(sec)
  22.     local str,d,h,m,s = "",_f(sec/86400),_f(sec/3600)%24,_f(sec/60)%60,_f(sec%60)
  23.     if d>0 then str = d>1 and d.." days " or "1 day " end
  24.     if h>0 then str = str..h.."h" end
  25.     if m>0 then str = str..(m>9 and m or "0"..m) end
  26.     if h==0 then str = m>0 and str..":"..(s>9 and s or "0"..s) or s.."s" end
  27.     return str
  28. end
  29. local w,h = term.getSize()
  30. local function computer()
  31.     term.setBackgroundColor(colors.white)
  32.     term.setTextColor(colors.black)
  33.     term.setCursorPos(1,1) term.clearLine()
  34.     term.write("#"..os.getComputerID().." - "..os.getComputerLabel())
  35.     term.setCursorPos(1,2) term.clearLine()
  36.     term.write("Running: "..strTime(os.clock()))
  37.     term.setBackgroundColor(colors.black)
  38.     term.setTextColour(colors.gray)
  39.     term.setCursorPos(1,3) term.clearLine()
  40.     term.write(string.rep(string.char(131),w))
  41.     term.setTextColor(colors.white)
  42. end
  43.  
  44. term.clear()
  45. computer()
  46. local batch,tick,e,p = os.startTimer(.1),os.startTimer(1)
  47. while true do
  48.     e,p = os.pullEvent("timer")
  49.     if p==batch then
  50.         os.cancelTimer(tick)
  51.         rs.setOutput("bottom",true)
  52.         crop()
  53.         dump()
  54.         rs.setOutput("bottom",false)
  55.         batch = os.startTimer(18*60) --18 min variable
  56.         tick = os.startTimer(1)
  57.     elseif p==tick then
  58.         computer()
  59.         tick = os.startTimer(1)
  60.     end
  61. end
Add Comment
Please, Sign In to add comment