Advertisement
RabaGhast

UselessBob

Nov 2nd, 2016
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.88 KB | None | 0 0
  1. t = 0.5
  2. loopTime = 0.1
  3. waiting = 100
  4.  
  5. pos = 0
  6.  
  7. function offLight()
  8.   if pos < 4 then
  9.     turtle.forward()
  10.     pos = pos + 1
  11.     print(pos)
  12.   else
  13.     turtle.attack()
  14.     rs.setOutput("bottom", false)
  15.     sleep(t)
  16.     rs.setOutput("bottom", true)
  17.     sleep(t)
  18.     rs.setOutput("bottom", false)
  19.   end
  20. end
  21.  
  22. function goHome()
  23.   if pos > 0 then
  24.     turtle.back()
  25.     pos = pos - 1
  26.     print(pos)
  27.   end
  28. end
  29.  
  30. while true do
  31.   if rs.getInput("top") then
  32.     while true do
  33.       offLight()
  34.       if not rs.getInput("top") then
  35.         break
  36.       end
  37.     end
  38.   end
  39.   if not rs.getInput("top") then
  40.     while true do
  41.       goHome()
  42.       if not rs.getInput("top") then
  43.         break
  44.       end
  45.     end
  46.   end
  47.   sleep(loopTime)
  48.   waiting = waiting - 1
  49.   if waiting <= 0 then
  50.     waiting = 100
  51.     print("hibernating")
  52.     os.pullEvent("redstone")
  53.   end
  54. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement