Advertisement
Guest User

Magepunk Main Computer Program

a guest
Jan 18th, 2015
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.90 KB | None | 0 0
  1. -- Each turtle program is assigned a uniqe color then the turtles are placed in a circle
  2. -- increases clockwise according to the following color list
  3.  
  4. --1 = white
  5. --2 = orange
  6. --4 = magenta
  7. --8 = lightBlue0
  8. --16 = yellow
  9. --32 = lime
  10. --64 = pink
  11. --128 = gray
  12. --256 = lightGray
  13. --512 = cyan
  14. --1024 = purple
  15. --2048 = blue
  16. --4096 = brown
  17. --8192 = green
  18. --16384 = red
  19. --32768 = black
  20.  
  21.  
  22. peds = {false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}
  23. pedposx = {4, 6, 7, 8, 10, 10, 10, 10, 10, 8, 7, 6, 4, 4, 4, 4 }
  24. pedposy = {2, 2, 2, 2, 2, 4, 5, 6, 8, 8, 8, 8, 8, 6, 5, 4 }
  25.  
  26. mon = peripheral.wrap("left")
  27.  
  28. reds = {1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8192,16384,32768}
  29.  
  30. mon.setBackgroundColor(colors.blue)
  31. mon.setTextScale(2)
  32. mon.clear()
  33.  
  34. function monreset()
  35. mon.setBackgroundColor(colors.blue)
  36. mon.clear()
  37. mon.setTextColor(colors.white)
  38. mon.setCursorPos(4, 9)
  39. mon.write("Pedestal")
  40. mon.setCursorPos(4, 10)
  41. mon.write("Selector")
  42. mon.setCursorPos(12, 1)
  43. mon.write("Presets")
  44. mon.setBackgroundColor(colors.purple)
  45. mon.setCursorPos(5, 3)
  46. mon.write(" ")
  47. mon.setBackgroundColor(colors.blue)
  48. end
  49.  
  50. function setReds()
  51. rstotal = 0
  52. for i=1,16 do
  53. if (peds[i]) then
  54. rstotal = rstotal + reds[i]
  55. end
  56. end
  57. rs.setBundledOutput("bottom", rstotal)
  58. end
  59.  
  60. function resetPeds()
  61. for i=1, 16 do
  62. peds[i] = false
  63. end
  64. end
  65.  
  66. function checkClick()
  67. event, side, xPos, yPos = os.pullEvent("monitor_touch")
  68. for i=1,16 do
  69. if (xPos == pedposx[i]) then
  70. if (yPos == pedposy[i]) then
  71. if (peds[i] == true) then
  72. peds[i] = false
  73. else
  74. peds[i] = true
  75. end
  76. end
  77. end
  78. end
  79.  
  80. if (xPos > 13) then
  81. if (xPos < 19) then
  82. if (yPos == 2) then
  83. resetPeds()
  84. peds[1] = true
  85. peds[9] = true
  86. end
  87. if (yPos == 3) then
  88. resetPeds()
  89. peds[3] = true
  90. peds[9] = true
  91. peds[13] = true
  92. end
  93. if (yPos == 4) then
  94. resetPeds()
  95. peds[3] = true
  96. peds[7] = true
  97. peds[11] = true
  98. peds[15] = true
  99. end
  100. if (yPos == 5) then
  101. resetPeds()
  102. peds[7] = true
  103. peds[4] = true
  104. peds[11] = true
  105. peds[1] = true
  106. peds[14] = true
  107. end
  108. if (yPos == 6) then
  109. resetPeds()
  110. peds[1] = true
  111. peds[4] = true
  112. peds[6] = true
  113. peds[9] = true
  114. peds[12] = true
  115. peds[14] = true
  116. end
  117. if (yPos == 7) then
  118. resetPeds()
  119. peds[1] = true
  120. peds[3] = true
  121. peds[5] = true
  122. peds[8] = true
  123. peds[10] = true
  124. peds[13] = true
  125. peds[15] = true
  126. end
  127. if (yPos == 8) then
  128. resetPeds()
  129. peds[1] = true
  130. peds[3] = true
  131. peds[5] = true
  132. peds[7] = true
  133. peds[9] = true
  134. peds[11] = true
  135. peds[13] = true
  136. peds[15] = true
  137. end
  138. if (yPos == 10) then
  139. resetPeds()
  140. end
  141. end
  142. end
  143. end
  144.  
  145. function showPeds()
  146. for i=1,16 do
  147. mon.setCursorPos(pedposx[i], pedposy[i])
  148. if (peds[i] == true) then
  149. mon.setBackgroundColor(colors.lime)
  150. mon.write(" ")
  151. else
  152. mon.setBackgroundColor(colors.black)
  153. mon.write(" ")
  154. end
  155. end
  156. end
  157.  
  158. function showPresets()
  159. mon.setBackgroundColor(colors.blue)
  160. mon.setCursorPos(14, 2)
  161. mon.write("Two")
  162. mon.setCursorPos(14, 3)
  163. mon.write("Three")
  164. mon.setCursorPos(14, 4)
  165. mon.write("Four")
  166. mon.setCursorPos(14, 5)
  167. mon.write("Five")
  168. mon.setCursorPos(14, 6)
  169. mon.write("Six")
  170. mon.setCursorPos(14, 7)
  171. mon.write("Seven")
  172. mon.setCursorPos(14, 8)
  173. mon.write("Eight")
  174. mon.setCursorPos(14, 10)
  175. mon.write("Reset")
  176. end
  177.  
  178. while true do
  179. monreset()
  180. setReds()
  181. showPeds()
  182. showPresets()
  183. checkClick()
  184. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement