Advertisement
demon012

Minecraft - Farm Computer

Feb 8th, 2015
294
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.88 KB | None | 0 0
  1. function floodField()
  2.     print("Flooding field")
  3.     rs.setOutput("right", true) -- flood the field
  4.     os.sleep(10)
  5.     rs.setOutput("right", false)
  6. end
  7.  
  8. local tickCount = 0
  9. local tickThreshold = 60000 -- 50 minutes
  10. local checkTimer = 60
  11.  
  12. if fs.exists("tickCount") then
  13.     file = io.open("tickCount", "r")
  14.     tickCount = file:read()
  15.     file:close()
  16. else
  17.     floodField()
  18. end
  19.  
  20. while true do
  21.     -- start timer
  22.     mainTimer = os.startTimer(checkTimer)
  23.  
  24.     -- wait for timer to elapse
  25.     event, event1, event2, event3 = os.pullEvent("timer")
  26.  
  27.     -- add ticks to tick counter
  28.     tickCount = tickCount + (checkTimer * 20)
  29.  
  30.     -- if tick counter greater than tick threshold then flood
  31.     if tickCount >= tickThreshold then
  32.         floodField()
  33.         tickCount = 0
  34.     end
  35.  
  36.     file = io.open("tickCount", "w")
  37.     file:write(tickCount)
  38.     file:close()
  39. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement