nSun

CC Cow feeder

Aug 27th, 2016
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.89 KB | None | 0 0
  1. local function output(line,str)
  2.     term.setCursorPos(1,line)
  3.     term.clearLine()
  4.     term.write(str)
  5. end
  6.  
  7. local function feed()
  8.     local wheat = turtle.getItemDetail(1)
  9.     if not wheat or wheat.name~="minecraft:wheat" then
  10.         error("Need wheat",0)
  11.         return
  12.     end
  13.     output(2,"Feeding..")
  14.     local count = 0
  15.     local limit = 255
  16.     local feed = true
  17.     turtle.select(1)
  18.  
  19.     while limit>0 and feed do
  20.         if not turtle.placeDown() then
  21.         limit = limit-1
  22.         else
  23.         count = count+1
  24.         limit = 255
  25.         end
  26.         output(3,count.." ("..limit..")")
  27.         feed = turtle.getItemCount(1)>5
  28.         sleep(.1)
  29.     end
  30.     output(3,"")
  31. end
  32.  
  33. output(string.format(1,"#%d - %s",
  34.     os.getComputerID(),
  35.     os.getComputerLabel))
  36. sleep(1)
  37. while true do
  38.     output(2,"Wait RS signal")
  39.     os.pullEvent("redstone")
  40.     feed()
  41.     local countdown = 10
  42.     while countdown>=0 do
  43.         output(2,"Countdown: "..countdown)
  44.         countdown = countdown-1
  45.         sleep(1)
  46.     end
  47. end
Advertisement
Add Comment
Please, Sign In to add comment