Advertisement
cyber_Ahn

Turtle_remote_npaint_turtle

Apr 3rd, 2015
421
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.63 KB | None | 0 0
  1. --need the 3dprint  by NITROGENFINGERS for the turtle http://pastebin.com/tzw1Sw78 user: http://pastebin.com/u/nitrogenfingers
  2.  
  3. local monitor_number = "monitor_1"
  4. local found = fs.exists("monitor.cfg")
  5. if found == true then
  6. file = fs.open("monitor.cfg","r")
  7. local fileData = {}
  8. local line = file.readLine()
  9. repeat
  10. table.insert(fileData,line)
  11. line = file.readLine()
  12. until line == nil
  13. file.close()
  14. monitor_number = fileData[1]
  15. end
  16. local mon = peripheral.wrap(monitor_number)
  17. os.loadAPI("caAPI")
  18. mon.setBackgroundColor(8)
  19. mon.clear()
  20. mon.setBackgroundColor(8)
  21. --ini
  22. local ModemSide = caAPI.detectDivice("modem")
  23. rednet.open(ModemSide)
  24. rednet.broadcast("$3Dmon.write ACTIVATE")
  25. sleep(1)
  26.  
  27. --function send
  28. function send(command)
  29. local msg = "$PC "..command
  30. rednet.broadcast(msg)
  31. end
  32.  
  33. --screen
  34. mon.setTextColor(1)
  35. mon.setCursorPos(1,1)
  36. mon.write("Turtle Remote")
  37. mon.setCursorPos(3,4)
  38. mon.write("^     *up")
  39. mon.setCursorPos(1,6)
  40. mon.write("<   >")
  41. mon.setCursorPos(3,8)
  42. mon.write("v     *down")
  43. mon.setCursorPos(1,10)
  44. mon.write("* exit")
  45. --touchscreen
  46. input = false
  47. while input == false do
  48. event,side,x,y = os.pullEvent()
  49. if event == "monitor_touch" or event == "mouse_click" then
  50. if x == 3 and y == 4 then
  51. send("FW")
  52. sleep(0.5)
  53. end
  54. if x == 1 and y == 6 then
  55. send("TL")
  56. sleep(0.5)
  57. end
  58. if x == 5 and y == 6 then
  59. send("TR")
  60. sleep(0.5)
  61. end
  62. if x == 3 and y == 8 then
  63. send("BK")
  64. sleep(0.5)
  65. end
  66. if x == 9 and y == 4 then
  67. send("UP")
  68. sleep(0.5)
  69. end
  70. if x == 9 and y == 8 then
  71. send("DW")
  72. sleep(0.5)
  73. end
  74. if x == 1 and y == 10 then
  75. input = true
  76. rednet.close(ModemSide)
  77. shell.run("clear")
  78. end
  79. end
  80. sleep(0.5)
  81. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement