Advertisement
ReportCards

Untitled

Jul 12th, 2023
16
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.76 KB | None | 0 0
  1. -- CraftOS - CC Tweaked - Number Pad GUI using Basalt GUI
  2. -- Monitor Size: 7, 5
  3. basalt = require("basalt")
  4. code = "1771"
  5. input = ""
  6. last_success = 0
  7. redstoneOn = false
  8.  
  9. main = basalt.createFrame()
  10. textField = main:addTextfield()
  11. :setPosition(1,5)
  12.  
  13. textField:addLine("In: ")
  14.  
  15. basalt:autoUpdate()
  16.  
  17. local function update()
  18. -- Input won't show up, just *'s'
  19. textField:editLine(1, string.rep("*", #input) .. string.rep("-", 4 - #input))
  20. end
  21.  
  22. local function check()
  23. if #input < 4 then
  24. return
  25. end
  26.  
  27. if input == code then
  28. input = ""
  29. last_success = os.clock()
  30. redstoneOn = true
  31. redstone.setOutput("back", true)
  32. update()
  33. else
  34. input = ""
  35. update()
  36. end
  37. end
  38.  
  39. local button1 = main
  40. :addButton()
  41. :setPosition(1,1)
  42. :setText("1")
  43. :setSize(1,1)
  44. :onClick(
  45. function()
  46. input = input .. "1"
  47. update()
  48. check()
  49. end)
  50.  
  51. local button2 = main
  52. :addButton()
  53. :setPosition(2,1)
  54. :setText("2")
  55. :setSize(1,1)
  56. :onClick(
  57. function()
  58. input = input .. "2"
  59. update()
  60. check()
  61. end)
  62.  
  63. local button3 = main
  64. :addButton()
  65. :setPosition(3,1)
  66. :setText("3")
  67. :setSize(1,1)
  68. :onClick(
  69. function()
  70. input = input .. "3"
  71. update()
  72. check()
  73. end)
  74.  
  75. local button4 = main
  76. :addButton()
  77. :setPosition(1,2)
  78. :setText("4")
  79. :setSize(1,1)
  80. :onClick(
  81. function()
  82. input = input .. "4"
  83. update()
  84. check()
  85. end)
  86.  
  87. local button5 = main
  88. :addButton()
  89. :setPosition(2,2)
  90. :setText("5")
  91. :setSize(1,1)
  92. :onClick(
  93. function()
  94. input = input .. "5"
  95. update()
  96. check()
  97. end)
  98.  
  99. local button6 = main
  100. :addButton()
  101. :setPosition(3,2)
  102. :setText("6")
  103. :setSize(1,1)
  104. :onClick(
  105. function()
  106. input = input .. "6"
  107. update()
  108. check()
  109. end)
  110.  
  111. local button7 = main
  112. :addButton()
  113. :setPosition(1,3)
  114. :setText("7")
  115. :setSize(1,1)
  116. :onClick(
  117. function()
  118. input = input .. "7"
  119. update()
  120. check()
  121. end)
  122.  
  123. local button8 = main
  124. :addButton()
  125. :setPosition(2,3)
  126. :setText("8")
  127. :setSize(1,1)
  128. :onClick(
  129. function()
  130. input = input .. "8"
  131. update()
  132. check()
  133. end)
  134.  
  135. local button9 = main
  136. :addButton()
  137. :setPosition(3,3)
  138. :setText("9")
  139. :setSize(1,1)
  140. :onClick(
  141. function()
  142. input = input .. "9"
  143. update()
  144. check()
  145. end)
  146.  
  147. local button0 = main
  148. :addButton()
  149. :setPosition(2,4)
  150. :setText("0")
  151. :setSize(1,1)
  152. :onClick(
  153. function()
  154. input = input .. "0"
  155. update()
  156. check()
  157. end)
  158.  
  159. while true do
  160. if os.clock() - last_success > 5 and redstoneOn then
  161. redstoneOn = false
  162. redstone.setOutput("back", false)
  163. end
  164. sleep(0.1)
  165. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement