Advertisement
infiniteblock

Untitled

Apr 25th, 2020
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.71 KB | None | 0 0
  1. ret1, ret2 = nil, nil --return for parallel functions
  2.  
  3. textStart = 11
  4.  
  5. function drawHeader()
  6.  
  7. -- Big B
  8. term.setBackgroundColor(colors.orange)
  9. term.setCursorPos(0, 1) term.write("2")
  10. term.setCursorPos(0, 1) term.write("1")
  11. term.setCursorPos(4, 8) term.write(" ")
  12.  
  13. -- Big M
  14. term.setBackgroundColor(colors.red)
  15. term.setCursorPos(4, 4) term.write(" ")
  16. term.setCursorPos(8, 4) term.write(" ")
  17. term.setCursorPos(4, 5) term.write(" ")
  18. term.setCursorPos(7, 5) term.write(" ")
  19. term.setCursorPos(10, 5) term.write(" ")
  20. term.setCursorPos(10, 6) term.write(" ")
  21.  
  22. -- Text
  23. term.setBackgroundColor(colors.black)
  24. term.setTextColor(colors.orange)
  25. term.setCursorPos(13, 5) term.write("Global Alliance Bank.")
  26. term.setTextColor(colors.white)
  27. term.setBackgroundColor(colors.black)
  28. end
  29.  
  30. function drawButtons()
  31. term.setBackgroundColor(colors.lightGray)
  32. term.setCursorPos(3, textStart) term.write(" ")
  33. term.setCursorPos(3, textStart + 2) term.write(" ")
  34. term.setCursorPos(3, textStart + 4) term.write(" ")
  35. term.setCursorPos(3, textStart + 6) term.write(" ")
  36.  
  37. term.setCursorPos(48, textStart) term.write(" ")
  38. term.setCursorPos(48, textStart + 2) term.write(" ")
  39. term.setCursorPos(48, textStart + 4) term.write(" ")
  40. term.setCursorPos(48, textStart + 6) term.write(" ")
  41.  
  42. term.setBackgroundColor(colors.black)
  43. end
  44.  
  45. function drawButton(button, text)
  46. local x, y
  47. if button == 1 then x = 6 y = textStart end
  48. if button == 2 then x = 6 y = textStart + 2 end
  49. if button == 3 then x = 6 y = textStart + 4 end
  50. if button == 4 then x = 6 y = textStart + 6 end
  51.  
  52. if button == 5 then x = 47 - #text y = textStart end
  53. if button == 6 then x = 47 - #text y = textStart + 2 end
  54. if button == 7 then x = 47 - #text y = textStart + 4 end
  55. if button == 8 then x = 47 - #text y = textStart + 6 end
  56.  
  57. term.setCursorPos(x, y)
  58. term.write(text)
  59. end
  60.  
  61. function drawError(error)
  62. -- Outer Triangle
  63. term.setBackgroundColor(colors.red)
  64. term.setCursorPos(12, textStart) term.write(" ")
  65. term.setCursorPos(11, textStart + 1) term.write(" ")
  66. term.setCursorPos(10, textStart + 2) term.write(" ")
  67. term.setCursorPos(9, textStart + 3) term.write(" ")
  68. term.setCursorPos(8, textStart + 4) term.write(" ")
  69. term.setCursorPos(7, textStart + 5) term.write(" ")
  70. term.setCursorPos(6, textStart + 6) term.write(" ")
  71.  
  72. term.setCursorPos(13, textStart + 1) term.write(" ")
  73. term.setCursorPos(14, textStart + 2) term.write(" ")
  74. term.setCursorPos(15, textStart + 3) term.write(" ")
  75. term.setCursorPos(16, textStart + 4) term.write(" ")
  76. term.setCursorPos(17, textStart + 5) term.write(" ")
  77.  
  78. -- Inner Triangle
  79. term.setBackgroundColor(colors.white)
  80. term.setCursorPos(12, textStart + 1) term.write(" ")
  81. term.setCursorPos(11, textStart + 2) term.write(" ")
  82. term.setCursorPos(10, textStart + 3) term.write(" ")
  83. term.setCursorPos(9, textStart + 4) term.write(" ")
  84. term.setCursorPos(8, textStart + 5) term.write(" ")
  85.  
  86. -- !
  87. term.setBackgroundColor(colors.black)
  88. term.setCursorPos(12, textStart + 2) term.write(" ")
  89. term.setCursorPos(12, textStart + 3) term.write(" ")
  90. term.setCursorPos(12, textStart + 5) term.write(" ")
  91.  
  92. -- Text
  93. term.setBackgroundColor(colors.black)
  94. term.setCursorPos(20, textStart) term.write(error)
  95.  
  96. term.setBackgroundColor(colors.black)
  97. end
  98.  
  99. function center(y, sText)
  100. local w, h = term.getSize()
  101. x = math.max(math.floor((w - #sText) / 2), 0)
  102. term.setCursorPos(x, y)
  103. print(sText)
  104. return x
  105. end
  106.  
  107. function waitForMouse()
  108. while true do
  109. local event, p1, p2, p3 = os.pullEvent("mouse_click")
  110. if p1 == 1 then
  111. ret1, ret2 = p2, p3
  112. return p2, p3
  113. end
  114. end
  115. end
  116.  
  117. function waitForButton()
  118. while true do
  119. local mx, my = waitForMouse()
  120. if my == textStart and mx >= 3 and mx <= 4 then ret1 = 1 return 1 end
  121. if my == textStart + 2 and mx >= 3 and mx <= 4 then ret1 = 2 return 2 end
  122. if my == textStart + 4 and mx >= 3 and mx <= 4 then ret1 = 3 return 3 end
  123. if my == textStart + 6 and mx >= 3 and mx <= 4 then ret1 = 4 return 4 end
  124.  
  125. if my == textStart and mx >= 48 and mx <= 49 then ret1 = 5 return 5 end
  126. if my == textStart + 2 and mx >= 48 and mx <= 49 then ret1 = 6 return 6 end
  127. if my == textStart + 4 and mx >= 48 and mx <= 49 then ret1 = 7 return 7 end
  128. if my == textStart + 6 and mx >= 48 and mx <= 49 then ret1 = 8 return 8 end
  129. end
  130. end
  131.  
  132. function waitForChar()
  133. while true do
  134. local event, p1 = os.pullEvent("char")
  135. ret1 = p1
  136. return p1
  137. end
  138. end
  139.  
  140. function waitForKey()
  141. while true do
  142. local event, p1 = os.pullEvent("key")
  143. ret1 = p1
  144. return p1
  145. end
  146. end
  147.  
  148. function waitForEnter()
  149. while true do
  150. local p1 = waitForKey()
  151. if p1 == 28 then
  152. return
  153. end
  154. end
  155. end
  156.  
  157. function waitForDisk()
  158. while true do
  159. local event, p1 = os.pullEvent("disk")
  160. return
  161. end
  162. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement