Advertisement
Guest User

startup

a guest
Nov 15th, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.96 KB | None | 0 0
  1. rednet.open("right")
  2. redstone.setOutput("left",false)
  3. modem = peripheral.wrap("right")
  4. modem.open(56)
  5. mon = peripheral.wrap("monitor_8")
  6.  
  7. term.redirect(mon)
  8. term.setBackgroundColor(colors.black)
  9. term.clear()
  10. term.setCursorPos(1,1)
  11. mon9 = peripheral.wrap("monitor_9")
  12. acess = false
  13.  
  14.  
  15. function createBox (name, xmin, xmax, ymin, ymax, text, color)
  16. currentY = ymin
  17. while currentY ~= ymax do
  18. term.setCursorPos(xmin, currentY)
  19. for i = 1, xmax do
  20. write(" ")
  21. end
  22. currentY = currentY + 1
  23. end
  24. end
  25.  
  26. function createButton (ymin, ymax, xmin, xmax, text, color)
  27. term.setBackgroundColor(color)
  28. xLoc = xmin + (math.ceil((xmax - string.len(text))/2))
  29. yLoc = math.ceil((ymax + ymin)/2)-1
  30. createBox(name, xmin, xmax, ymin, ymax, text, color)
  31. term.setCursorPos(xLoc,yLoc)
  32. write(text)
  33. end
  34.  
  35.  
  36. function digi()
  37. mon9.setBackgroundColor(colors.black)
  38. mon9.clear()
  39. mon9.setBackgroundColor(colors.orange)
  40. mon9.setCursorPos(2,3)
  41. mon9.write("open")
  42. term.setBackgroundColor(colors.black)
  43. term.clear()
  44.  
  45. x1 = 4
  46. x2 = 9
  47. x3 = 14
  48. t1 = 3
  49. y1 = 2
  50. y2 = 5
  51. y3 = 8
  52. yx1 = y1+2
  53. yx2 = y2+2
  54. yx3 = y3+2
  55. createButton(y1,yx1 , x1, t1, "1", colors.orange    )
  56. createButton(y1,yx1, x2, t1, "2", colors.orange     )
  57. createButton(y1, yx1, x3, t1, "3", colors.orange    )
  58. createButton(y2, yx2, x1, t1, "4", colors.orange    )
  59. createButton(y2, yx2, x2, t1, "5", colors.orange    )
  60. createButton(y2, yx2, x3, t1, "6", colors.orange    )
  61. createButton(y3, yx3, x1, t1, "7", colors.orange    )
  62. createButton(y3, yx3, x2, t1, "8", colors.orange    )
  63. createButton(y3, yx3, x3, t1, "9", colors.orange    )
  64. createButton(11, 13, 8, 5, "0", colors.orange   )
  65. end
  66.  
  67.  
  68. function click()
  69. event, side, x, y = os.pullEvent("monitor_touch")
  70. if side == "monitor_8" then
  71. data = compare(x,y)
  72. return (data)
  73. elseif side == "monitor_9"  then
  74. redstone.setOutput("left",true)
  75. sleep(10)
  76. redstone.setOutput("left",false)
  77. end
  78. --end
  79.  
  80. end
  81.  
  82. function compare(x,y)
  83.  
  84. x1 = 4
  85. x2 = 9
  86. x3 = 14
  87. t1 = 3
  88. y1 = 2
  89. y2 = 5
  90. y3 = 8
  91. yx1 = y1+2
  92. yx2 = y2+2
  93. yx3 = y3+2
  94.  
  95. data = 0
  96. if x < 7 and x > 3 and y < 4 and y > 1 then
  97. data = 1
  98. createButton(y1,yx1 , x1, t1, "1", colors.red)
  99. elseif x < 12 and x > 8 and y < 4 and y > 1 then
  100. data = 2
  101. createButton(y1,yx1, x2, t1, "2", colors.red)
  102. elseif x < 17 and x > 13 and y < 4 and y > 1 then
  103. data = 3
  104. createButton(y1, yx1, x3, t1, "3", colors.red)
  105. elseif x < 7 and x > 3 and y < 7 and y > 4 then
  106. data = 4
  107. createButton(y2, yx2, x1, t1, "4", colors.red)
  108. elseif x < 12 and x > 8 and y < 7 and y > 4 then
  109. data = 5
  110. createButton(y2, yx2, x2, t1, "5", colors.red)
  111. elseif x < 17 and x > 13 and y < 7 and y > 4 then
  112. data = 6
  113. createButton(y2, yx2, x3, t1, "6", colors.red)
  114. elseif x < 7 and x > 3 and y < 10 and y > 7 then
  115. data = 7
  116. createButton(y3, yx3, x1, t1, "7", colors.red)
  117. elseif x < 12 and x > 8 and y < 10 and y > 7 then
  118. data = 8
  119. createButton(y3, yx3, x2, t1, "8", colors.red)
  120. elseif x < 17 and x > 13 and y < 10 and y > 7 then
  121. data = 9
  122. createButton(y3, yx3, x3, t1, "9", colors.red)
  123. elseif x < 13 and x > 7 and y < 13 and y > 10 then
  124. data = 0
  125. createButton(11, 13, 8, 5, "0", colors.red)
  126. else
  127. data = nil
  128. end
  129. if data ~= nil then
  130. sleep(1)
  131. return (data)
  132. end
  133. end
  134.  
  135. while (true) do
  136. if acess == true then
  137. --id,msg,dis = rednet.receive()
  138. redstone.setOutput("left", false)
  139. acess = false
  140. end
  141. digi()
  142. acess = false
  143. data1, data2, data3, data4 = nil
  144. while (acess == false) do
  145. digi()
  146. data = click()
  147. if data1 == nil then
  148. data1 = data
  149. elseif data2 == nil then
  150. data2 = data
  151. elseif data3 == nil then
  152. data3 = data
  153. elseif data4 == nil then
  154. data4 = data
  155. else
  156. data1 = data2
  157. data2 = data3
  158. data3 = data4
  159. data4 = data
  160. end
  161. if data1 == 2 and data2 == 0 and data3 == 1 and data4 == 2 then
  162. acess = true
  163. end
  164. end
  165. term.setBackgroundColor(colors.black)
  166. term.clear()
  167. term.setCursorPos(1,1)
  168.  
  169. if acess == true then
  170. resultat = "bienvenue ! ^^"
  171. modem.transmit(56,56,"ouverture")
  172. redstone.setOutput("left",true)
  173. --rednet.send (56,msg)
  174. createButton(4, 7, 3, 15, resultat, colors.red)
  175. sleep(10)
  176. term.clear()
  177. end
  178. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement