Advertisement
Guest User

startup

a guest
Jul 19th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.30 KB | None | 0 0
  1. m = peripheral.wrap("left")
  2. term.clear()
  3. passwort = 1379
  4. count = 0
  5. a = 0
  6. b = 0
  7. c = 0
  8. d = 0
  9. eingabe = 0
  10. zugang = 0
  11.  
  12. function Rahmen()
  13. m.clear()
  14. m.setBackgroundColor(8)
  15. m.setCursorPos(3,1)
  16. m.write("123")
  17. m.setCursorPos(3,2)
  18. m.write("456")
  19. m.setCursorPos(3,3)
  20. m.write("789")
  21. end
  22.  
  23. m.setBackgroundColor(32768)
  24.  
  25. function Eingabe()
  26. while count < 4 do
  27. event,side,x,y = os.pullEvent()
  28. if event == "monitor_touch" then
  29.  
  30. if x == 3 and y == 1 then
  31. count = count + 1
  32. if count == 1 then
  33. a = 1
  34. m.setBackgroundColor(32768)
  35. m.setCursorPos(3,4)
  36. m.write("*")
  37. elseif count == 2 then
  38. b = 1
  39. m.write("*")
  40. elseif count == 3 then
  41. c = 1
  42. m.write("*")
  43. elseif count == 4 then
  44. d = 1
  45. m.write("*")
  46. end
  47. end
  48.  
  49. if x == 4 and y == 1 then
  50. count =  count + 1
  51. if count == 1 then
  52. a = 2
  53. m.setBackgroundColor(32768)
  54. m.setCursorPos(3,4)
  55. m.write("*")
  56. elseif count == 2 then
  57. b = 2
  58. m.write("*")
  59. elseif count == 3 then
  60. c = 2
  61. write("*")
  62. elseif count == 4 then
  63. d = 2
  64. m.write("*")
  65. end
  66. end
  67.  
  68. if x == 5 and y == 1 then
  69. count = count + 1
  70. if count == 1 then
  71. a = 3
  72. m.setBackgroundColor(32768)
  73. m.setCursorPos(3,4)
  74. m.write("*")
  75. elseif count == 2 then
  76. b = 3
  77. m.write("*")
  78. elseif count == 3 then
  79. c = 3
  80. m.write("*")
  81. elseif count == 4 then
  82. d = 3
  83. m.write("*")
  84. end
  85. end
  86.  
  87. if x == 3 and y == 2 then
  88. count = count + 1
  89. if count == 1 then
  90. a = 4
  91. m.setBackgroundColor(32768)
  92. m.setCursorPos(3,4)
  93. m.write("*")
  94. elseif count == 2 then
  95. b = 4
  96. m.write("*")
  97. elseif count == 3 then
  98. c = 4
  99. m.write("*")
  100. elseif count == 4 then
  101. d = 4
  102. m.write("*")
  103. end
  104. end
  105.  
  106. if x == 4  and y == 2 then
  107. count = count + 1
  108. if count == 1 then
  109. a = 5
  110. m.setBackgroundColor(32768)
  111. m.setCursorPos(3,4)
  112. write("*")
  113. elseif count == 2 then
  114. b = 5
  115. m.write("*")
  116. elseif count == 3 then
  117. c = 5
  118. m.write("*")
  119. elseif count == 4 then
  120. d = 5
  121. m.write("*")
  122. end
  123. end
  124.  
  125. if x == 5 and y == 2 then
  126. count = count + 1
  127. if count == 1 then
  128. a = 6
  129. m.setBackgroundColor(32768)
  130. m.setCursorPos(3,4)
  131. m.write("*")
  132. elseif count == 2 then
  133. b = 6
  134. m.write("*")
  135. elseif count == 3 then
  136. c = 6
  137. m.write("*")
  138. elseif count == 4 then
  139. d = 6
  140. m.write("*")
  141. end
  142. end
  143.  
  144. if x == 3 and y == 3 then
  145. count = count + 1
  146. if count == 1 then
  147. a = 7
  148. m.setBackgroundColor(32768)
  149. m.setCursorPos(3,4)
  150. m.write("*")
  151. elseif count == 2 then
  152. b = 7
  153. m.write("*")
  154. elseif count == 3 then
  155. c = 7
  156. m.write("*")
  157. elseif count == 4 then
  158. d = 7
  159. m.write("*")
  160. end
  161. end
  162.  
  163. if x == 4 and y == 3 then
  164. count = count + 1
  165. if count == 1 then
  166. a = 8
  167. m.setBackgroundColor(32768)
  168. m.setCursorPos(3,4)
  169. m.write("*")
  170. elseif count == 2 then
  171. b = 8
  172. m.write("*")
  173. elseif count == 3 then
  174. c = 8
  175. m.write("*")
  176. elseif count == 4 then
  177. d = 8
  178. m.write("*")
  179. end
  180. end
  181.  
  182. if x == 5 and y == 3 then
  183. count = count + 1
  184. if count == 1 then
  185. a = 9
  186. m.setBackgroundColor(32768)
  187. m.setCursorPos(3,4)
  188. m.write("*")
  189. elseif count == 2 then
  190. b = 9
  191. m.write("*")
  192. elseif count == 3 then
  193. c = 9
  194. m.write("*")
  195. elseif count == 4 then
  196. d = 9
  197. m.write("*")
  198. end
  199. end
  200.  
  201. end
  202. end
  203. count = 0
  204. end
  205.  
  206. while true do
  207. Rahmen()
  208. Eingabe()
  209.  
  210. m.setCursorPos(2,5)
  211. eingabe = (""..a..""..b..""..c..""..d.."")
  212. zugang = (passwort - eingabe)
  213. if zugang == 0 then
  214. m.setCursorPos(2,5)
  215. m.write("OK")
  216. rs.setOutput("bottom", true)
  217. sleep(3)
  218. rs.setOutput("bottom", false)
  219. else m.write("FALSCH")
  220. end
  221.  
  222. sleep(3)
  223. m.setBackgroundColor(32768)
  224. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement