Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- rednet.open("right")
- con = "false"
- 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
- -- screen display
- term.clear()
- x,y = term.getSize()
- term.setCursorPos(x/2, y/3-1)
- print("W")
- term.setCursorPos(x/2-3, y/3)
- print("Forward")
- 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")
- while true do
- event, param = os.pullEvent()
- if param ~= 31 and event == "key" then
- if pos == "top" then
- 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
- if param == 17 then
- eng.move(2, false, false)
- os.sleep(1)
- turtle.forward()
- elseif param == 32 then
- eng.move(5, false, false)
- turtle.turnRight()
- turtle.forward()
- turtle.turnLeft()
- sleep(.2)
- elseif param == 30 then
- eng.move(4, false, false)
- turtle.turnLeft()
- turtle.forward()
- turtle.turnRight()
- sleep(.2)
- elseif param == 42 then
- eng.move(1, false, false)
- turtle.up()
- sleep(1)
- elseif param == 29 then
- eng.move(0, false, false)
- turtle.down()
- sleep(1)
- end
- elseif param == 31 then
- if pos == "back" then
- 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
- eng.move(3, false, false)
- turtle.forward()
- sleep(1)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement