Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- rednet.open("right")
- con = "off"
- function topToBack() -- move turtle from top of controller to back
- turtle.forward()
- turtle.down()
- turtle.turnRight()
- turtle.turnRight()
- pos = "back"
- file = fs.open("pos", "w")
- file.write(pos)
- file:close()
- eng = peripheral.wrap("front")
- end
- function backToTop() -- move turtle from behind engine to top
- turtle.up()
- turtle.forward()
- turtle.turnRight()
- turtle.turnRight()
- pos = "top"
- file = fs.open("pos", "w")
- file.write(pos)
- file:close()
- eng = peripheral.wrap("bottom")
- end
- -- screen display
- term.clear()
- x,y = term.getSize()
- term.setCursorPos(x/2, y/3-1)
- print("W")
- term.setCursorPos(x/5*4, y/3-1)
- print("Auto(R)")
- term.setCursorPos(x/2-3, y/3)
- print("Forward")
- term.setCursorPos(x/5*4, y/3)
- print(con)
- term.setCursorPos(x/5, y/3*2)
- print("A")
- term.setCursorPos(x/2, y/3*2)
- print("S")
- term.setCursorPos(x/5*4, y/3*2)
- print("D")
- term.setCursorPos(x/5-2, y/3*2+1)
- print("Left")
- term.setCursorPos(x/2-2, y/3*2+1)
- print("Back")
- term.setCursorPos(x/5*4-2, y/3*2+1)
- print("Right")
- term.setCursorPos(1, y-3)
- print("[Shift]")
- term.setCursorPos(3,y-2)
- print("Up")
- term.setCursorPos(1, y-1)
- print("[Ctrl]")
- term.setCursorPos(2, y)
- print("Down")
- -- determine turtle position above or behind the engine
- result = fs.exists("pos")
- if result == true then
- file = io.open("pos", "r")
- pos = file.read()
- file:close()
- else
- pos = "back"
- file = fs.open("pos", "w")
- file.write(pos)
- file:close()
- end
- if pos == "back" then
- eng = peripheral.wrap("front")
- else
- eng = peripheral.wrap("bottom")
- end
- while true do
- timeout = os.startTimer(0.5)
- event, param = os.pullEvent()
- if event == "timer" then
- if con == "on" then
- if dir ~= 31 then
- if pos == "top" then
- topToBack()
- end
- if dir == 17 then
- dir = 17
- eng.move(2, false, false)
- os.sleep(1)
- turtle.forward()
- elseif dir == 32 then
- dir = 32
- eng.move(5, false, false)
- turtle.turnRight()
- turtle.forward()
- turtle.turnLeft()
- sleep(.2)
- elseif dir == 30 then
- dir = 30
- eng.move(4, false, false)
- turtle.turnLeft()
- turtle.forward()
- turtle.turnRight()
- sleep(.2)
- elseif dir == 42 then
- dir = 42
- eng.move(1, false, false)
- turtle.up()
- sleep(1)
- elseif dir == 29 then
- dir = 29
- eng.move(0, false, false)
- turtle.down()
- sleep(1)
- end
- elseif dir == 31 then
- dir = 31
- if pos == "back" then
- backToTop()
- end
- eng.move(3, false, false)
- turtle.forward()
- sleep(1)
- end
- end
- end
- if param ~= 31 and event == "key" then
- if pos == "top" then
- topToBack()
- end
- if param == 17 then
- dir = 17
- eng.move(2, false, false)
- os.sleep(1)
- turtle.forward()
- elseif param == 32 then
- dir = 32
- eng.move(5, false, false)
- turtle.turnRight()
- turtle.forward()
- turtle.turnLeft()
- sleep(.2)
- elseif param == 30 then
- dir = 30
- eng.move(4, false, false)
- turtle.turnLeft()
- turtle.forward()
- turtle.turnRight()
- sleep(.2)
- elseif param == 42 then
- dir = 42
- eng.move(1, false, false)
- turtle.up()
- sleep(1)
- elseif param == 29 then
- dir = 29
- eng.move(0, false, false)
- turtle.down()
- sleep(1)
- elseif param == 19 then
- if con == "on" then
- con = "off"
- else
- con = "on"
- end
- os.sleep(0.5)
- dir = nil
- term.setCursorPos(x/5*4, y/3-1)
- print(con.." ")
- end
- elseif param == 31 then
- dir = 31
- if pos == "back" then
- backToTop()
- end
- eng.move(3, false, false)
- turtle.forward()
- sleep(1)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement