Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- os.loadAPI("action")
- redState = rs.getInput("bottom")
- hallway = true
- battery = 100 --need to implement
- function goShort()
- count = 0
- while count < 32 do
- count = move(count)
- if count == 17 and hallway then
- if not action.recharge() then
- hallway = not hallway
- end
- end
- end
- turtle.turnRight()
- hallway = not hallway
- goLong()
- end
- function goLong()
- count = 0
- while count < 50 do
- count = move(count)
- end
- turtle.turnRight()
- goShort()
- end
- function move(count)
- turtle.forward()
- if turtle.detect() then
- turtle.back()
- turtle.turnRight()
- if count > 32 then
- goShort()
- else
- goLong()
- end
- end
- if not redState == rs.getInput("bottom") then
- redState = rs.getInput("bottom")
- return count + 1
- else
- soundAlarm()
- return count
- end
- end
- function soundAlarm()
- --Debug!
- print(rednet.send(3, "Alarm!")) -- 3 being the terminal ID
- print("Alarm!")
- end
- rednet.open("right")
- term.clear()
- term.setCursorPos(1,1)
- print("Chaosoft Corp. Security Drone")
- goLong()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement