Advertisement
Theo123456

Porte code

Aug 8th, 2015
224
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.63 KB | None | 0 0
  1. os.pullEvent = os.pullEventRaw
  2.  
  3. codeT = "1234"
  4. debug = "0000"
  5. attente = tonumber("3")
  6. cote = "back"
  7. -- front(devant), back(derriere), top(dessus), bottom(dessous), left(gauche), right(droite)
  8. inversion = "oui"
  9.  
  10. sortie = "0"
  11. if inversion == "oui" then
  12. redstone.setOutput(cote, true)
  13. end
  14.  
  15. while sortie == "0" do
  16. term.clear()
  17. term.setCursorPos(17,2)
  18. print("Inserez votre code")
  19. term.setCursorPos(18,4)
  20. print("*---**---**---*")
  21. term.setCursorPos(18,5)
  22. print("| 1 || 2 || 3 |")
  23. term.setCursorPos(18,6)
  24. print("*---**---**---*")
  25. term.setCursorPos(18,7)
  26. print("*---**---**---*")
  27. term.setCursorPos(18,8)
  28. print("| 4 || 5 || 6 |")
  29. term.setCursorPos(18,9)
  30. print("*---**---**---*")
  31. term.setCursorPos(18,10)
  32. print("*---**---**---*")
  33. term.setCursorPos(18,11)
  34. print("| 7 || 8 || 9 |")
  35. term.setCursorPos(18,12)
  36. print("*---**---**---*")
  37. term.setCursorPos(18,13)
  38. print("*---**---**---*")
  39. term.setCursorPos(18,14)
  40. print("|EFF|| 0 ||VAL|")
  41. term.setCursorPos(18,15)
  42. print("*---**---**---*")
  43. code = ""
  44. ok = tonumber("4")
  45. while ok ~= 5 do
  46. term.setCursorPos(22,17)
  47. if ok == 4 then
  48. print("_ _ _ _")
  49. elseif ok == 3 then
  50. print("* _ _ _")
  51. elseif ok == 2 then
  52. print("* * _ _")
  53. elseif ok == 1 then
  54. print("* * * _")
  55. elseif ok == 0 then
  56. print("* * * *")
  57. end
  58. event, button, x, y = os.pullEvent("mouse_click")
  59. if x == nil or y == nil or button == nil then
  60. elseif x >= 18 and x <= 22 and y >= 4 and y <= 6 and button == 1 then
  61. code = code.."1"
  62. ok = ok - 1
  63. elseif x >= 23 and x <= 27 and y >= 4 and y <= 6 and button == 1 then
  64. code = code.."2"
  65. ok = ok - 1
  66. elseif x >= 28 and x <= 32 and y >= 4 and y <= 6 and button == 1 then
  67. code = code.."3"
  68. ok = ok - 1
  69. elseif x >= 18 and x <= 22 and y >= 7 and y <= 9 and button == 1 then
  70. code = code.."4"
  71. ok = ok - 1
  72. elseif x >= 23 and x <= 27 and y >= 7 and y <= 9 and button == 1 then
  73. code = code.."5"
  74. ok = ok - 1
  75. elseif x >= 28 and x <= 32 and y >= 7 and y <= 9 and button == 1 then
  76. code = code.."6"
  77. ok = ok - 1
  78. elseif x >= 18 and x <= 22 and y >= 10 and y <= 12 and button == 1 then
  79. code = code.."7"
  80. ok = ok - 1
  81. elseif x >= 23 and x <= 27 and y >= 10 and y <= 12 and button == 1 then
  82. code = code.."8"
  83. ok = ok - 1
  84. elseif x >= 28 and x <= 32 and y >= 10 and y <= 12 and button == 1 then
  85. code = code.."9"
  86. ok = ok - 1
  87. elseif x >= 18 and x <= 22 and y >= 13 and y <= 15 and button == 1 then
  88. code = ""
  89. ok = tonumber("4")
  90. elseif x >= 23 and x <= 27 and y >= 13 and y <= 15 and button == 1 then
  91. code = code.."0"
  92. ok = ok - 1
  93. elseif x >= 28 and x <= 32 and y >= 13 and y <= 15 and button == 1 then
  94. if ok == 0 then
  95. ok = tonumber("5")
  96. end
  97. end
  98. if ok < 0 then
  99. ok = tonumber("0")
  100. end
  101. end
  102. term.setCursorPos(1,2)
  103. if code == codeT then
  104. print(" ACCEPTE ")
  105. if inversion == "non" then
  106. redstone.setOutput(cote, true)
  107. sleep(attente)
  108. redstone.setOutput(cote, false)
  109. elseif inversion == "oui" then
  110. redstone.setOutput(cote, false)
  111. sleep(attente)
  112. redstone.setOutput(cote, true)
  113. end
  114. elseif code == debug then
  115. sortie = "1"
  116. term.clear()
  117. term.setCursorPos(1,1)
  118. term.setTextColor(colors.yellow)
  119. print("CodeOS 1.0")
  120. term.setTextColor(colors.white)
  121. else
  122. print(" REFUSE ")
  123. sleep(attente)
  124. end
  125. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement