Advertisement
ReportCards

Untitled

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