Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- t = 0.5
- loopTime = 0.1
- waiting = 100
- pos = 0
- function offLight()
- if pos < 4 then
- turtle.forward()
- pos = pos + 1
- print(pos)
- else
- turtle.attack()
- rs.setOutput("bottom", false)
- sleep(t)
- rs.setOutput("bottom", true)
- sleep(t)
- rs.setOutput("bottom", false)
- end
- end
- function goHome()
- if pos > 0 then
- turtle.back()
- pos = pos - 1
- print(pos)
- end
- end
- while true do
- if rs.getInput("top") then
- while true do
- offLight()
- if not rs.getInput("top") then
- break
- end
- end
- end
- if not rs.getInput("top") then
- while true do
- goHome()
- if not rs.getInput("top") then
- break
- end
- end
- end
- sleep(loopTime)
- waiting = waiting - 1
- if waiting <= 0 then
- waiting = 100
- print("hibernating")
- os.pullEvent("redstone")
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement