Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --THINGS TO ADD: Fuel meter, auto startup, "connect to turtle" - which wakes the turtle?
- local isRunning = true
- function Quit()
- isRunning = false
- term.setCursorPos(1,1)
- term.setBackgroundColour(colours.black)
- term.setTextColour(colours.white)
- term.clear()
- error()
- end
- local function getModem()
- for a,b in pairs(rs.getSides()) do
- if peripheral.getType(b) == "modem" and peripheral.call(b,"isWireless") then
- return b
- end
- end
- end
- while isRunning do
- notclicked = true
- side = getModem()
- rednet.open(side)
- term.setBackgroundColor(colors.white)
- term.setCursorPos(1,1)
- term.clear()
- term.setTextColor(colors.blue)
- print("Turtle Control")
- term.setTextColor(colors.lime)
- paintutils.drawFilledBox(2,2,10,5,colors.yellow) -- Forward
- paintutils.drawFilledBox(16,2,24,5,colors.yellow) -- Backward
- paintutils.drawFilledBox(2,7,10,10,colors.yellow) -- Left
- paintutils.drawFilledBox(16,7,24,10,colors.yellow) -- Right
- paintutils.drawFilledBox(2,12,10,15,colors.yellow) -- Turn Left
- paintutils.drawFilledBox(16,12,24,15,colors.yellow) -- Turn Right
- paintutils.drawFilledBox(2,18,10,20,colors.yellow) -- Action
- paintutils.drawFilledBox(16,18,24,20,colors.red) -- Exit
- term.setCursorPos(3,4)
- print("Forward")
- term.setCursorPos(16,4)
- print("Backward")
- term.setCursorPos(4,9)
- print("Left")
- term.setCursorPos(18,9)
- print("Right")
- term.setCursorPos(4,13)
- print("Turn")
- term.setCursorPos(4,14)
- print("Left")
- term.setCursorPos(18,13)
- print("Turn")
- term.setCursorPos(18,14)
- print("Right")
- term.setCursorPos(4,19)
- print("Action")
- term.setCursorPos(18,19)
- print("Quit")
- while notclicked do
- event,button,x,y = os.pullEvent("mouse_click")
- if x == 2 and y == 2 or x == 10 and y == 5 or x > 2 and x < 10 and y > 2 and y < 5 then
- rednet.open(side)
- rednet.broadcast("forward")
- rednet.close(side)
- elseif x == 16 and y == 2 or x == 24 and y == 5 or x > 16 and x < 24 and y > 2 and y < 5 then
- rednet.open(side)
- rednet.broadcast("backwards")
- rednet.close(side)
- elseif x == 2 and y == 7 or x == 10 and y == 10 or x > 2 and x < 10 and y > 7 and y < 10 then
- rednet.open(side)
- rednet.broadcast("left")
- rednet.close(side)
- elseif x == 16 and y == 7 or x == 24 and y == 10 or x > 16 and x < 24 and y > 7 and y < 10 then
- rednet.open(side)
- rednet.broadcast("right")
- rednet.close(side)
- elseif x == 2 and y == 12 or x == 10 and y == 15 or x > 2 and x < 10 and y > 12 and y < 15 then
- rednet.open(side)
- rednet.broadcast("turnleft")
- rednet.close()
- elseif x == 16 and y == 12 or x == 24 and y == 15 or x > 16 and x < 24 and y > 12 and y < 15 then
- rednet.open(side)
- rednet.broadcast("turnright")
- rednet.close()
- elseif x == 2 and y == 18 or x == 10 and y == 20 or x > 2 and x < 10 and y > 18 and y < 20 then
- rednet.open(side)
- rednet.broadcast("action")
- rednet.close()
- elseif x == 16 and y == 18 or x == 24 and y == 20 or x > 16 and x < 24 and y > 18 and y < 20 then
- rednet.open(side)
- rednet.broadcast("quit")
- rednet.close()
- Quit()
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement