Advertisement
Guest User

Untitled

a guest
Jun 25th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.88 KB | None | 0 0
  1. term.clear()
  2.  
  3. function loop()
  4. page = "main"
  5. animate = true
  6. while true do
  7. screen(page)
  8. animate = false
  9. listen()
  10.  
  11. if page == "main" then
  12.  
  13. if event == "mouse_click" then
  14. if x >= 3 and x <= 12 then
  15. if y >= 3 and y <= 5 then
  16. flash("Onward", 3, 12, 3, 5, colors.lime, colors.red)
  17. elseif y >= 7 and y <= 9 then
  18. flash("Backward", 3, 12, 7, 9, colors.lime, colors.red)
  19. elseif y >= 11 and y <= 13 then
  20. flash("StrafeLT", 3, 12, 11, 13, colors.lime, colors.red)
  21. elseif y == 15 then
  22. flash("Attack", 3, 12, 15, 15, colors.lime, colors.red)
  23. elseif y == 17 then
  24. flash("Detect", 3, 12, 17, 17, colors.lime, colors.red)
  25. elseif y == 19 then
  26. flash("Info", 3, 12, 19, 19, colors.lime, colors.red)
  27. end
  28. elseif x >= 15 and x <= 24 then
  29. if y >= 3 and y <= 5 then
  30. flash("GoUp", 15, 24, 3, 5, colors.lime, colors.red)
  31. elseif y >= 7 and y <= 9 then
  32. flash("GoDown", 15, 24, 7, 9, colors.lime, colors.red)
  33. elseif y >= 11 and y <= 13 then
  34. flash("StrafeRT", 15, 24, 11, 13, colors.lime, colors.red)
  35. elseif y == 15 then
  36.  
  37. elseif y == 17 then
  38.  
  39. elseif y == 19 then
  40.  
  41. end
  42. end
  43.  
  44. elseif event == "key" then
  45. if keyID == 17 then
  46. flash("Onward", 3, 12, 3, 5, colors.lime, colors.red)
  47. elseif keyID == 203 then
  48. flash("StrafeLT", 3, 12, 11, 13, colors.lime, colors.red)
  49. elseif keyID == 31 then
  50. flash("Backward", 3, 12, 7, 9, colors.lime, colors.red)
  51. elseif keyID == 205 then
  52. flash("StrafeRT", 15, 24, 11, 13, colors.lime, colors.red)
  53. elseif keyID == 208 then
  54. flash("GoDown", 15, 24, 7, 9, colors.lime, colors.red)
  55. elseif keyID == 200 then
  56. flash("GoUp", 15, 24, 3, 5, colors.lime, colors.red)
  57. elseif keyID == 30 then
  58. flash("Attack", 3, 12, 15, 15, colors.lime, colors.red)
  59. elseif keyID == 32 then
  60. flash("Detect", 3, 12, 17, 17, colors.lime, colors.red)
  61. elseif keyID == 23 then
  62. flash("Info", 3, 12, 19, 19, colors.lime, colors.red)
  63. end
  64. end
  65. end
  66. end
  67. end
  68.  
  69. function getCoords()
  70. id, cX = rednet.receive()
  71. id, cY = rednet.receive()
  72. id, cZ = rednet.receive()
  73.  
  74. if not cX or not cY or not cZ then
  75. tX = math.ceil((width-6)/2)
  76. term.setCursorPos(tX, 25)
  77. term.write("failed")
  78. else
  79. str = "(x, y, z): "..cX..", "..cY..", "..cZ
  80. tX = math.ceil((width-#str)/2)
  81. term.setCursorPos(tX, 25)
  82. term.write(str)
  83. end
  84. end
  85.  
  86. function screen(page)
  87. rect("Turtle OS V1.0", 1, 26, 1, 1, colors.black)
  88. if page == "main" then
  89. --rect("12345678", 3, 12, 11, 13, colors.red)
  90. rect("Onward", 3, 12, 3, 5, colors.red)
  91. rect("GoUp", 15, 24, 3, 5, colors.red)
  92.  
  93. rect("Backward", 3, 12, 7, 9, colors.red)
  94. rect("GoDown", 15, 24, 7, 9, colors.red)
  95.  
  96. rect("StrafeLT", 3, 12, 11, 13, colors.red)
  97. rect("StrafeRT", 15, 24, 11, 13, colors.red)
  98.  
  99. rect("Attack", 3, 12, 15, 15, colors.red)
  100. rect("Detect", 3, 12, 17, 17, colors.red)
  101.  
  102. rect("PlaceBlock", 15, 24, 15, 15, colors.red)
  103. rect("Locate", 15, 24, 17, 17, colors.red)
  104.  
  105. rect("Info", 3, 12, 19, 19, colors.red)
  106. rect("System", 15, 24, 19, 19, colors.red)
  107. end
  108. end
  109.  
  110. function rect(label, xA, xB, yA, yB, col)
  111. pC = term.getBackgroundColor()
  112. term.setBackgroundColor(col)
  113. for x = xA, xB do
  114. for y = yA, yB do
  115. term.setCursorPos(x, y)
  116. term.write(" ")
  117. if animate == true then
  118. sleep(0.0001)
  119. end
  120. end
  121. end
  122. lX = math.ceil((xA+xB-#label)/2)
  123. lY = math.ceil((yA+yB)/2)
  124. term.setCursorPos(lX, lY)
  125. term.write(label)
  126. end
  127.  
  128. function flash(label, xA, xB, yA, yB, fC, bC)
  129. rect(label, xA, xB, yA, yB, fC)
  130. sleep(0.15)
  131. rect(label, xA, xB, yA, yB, bC)
  132. end
  133.  
  134. function listen()
  135. event, keyID, x, y = os.pullEvent()
  136. end
  137.  
  138. function send(msg)
  139. rednet.send(turtleID, msg)
  140. end
  141.  
  142. rednet.open("back")
  143. turtleID = 5
  144. loop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement