benthomas7777

BM-Bank GUI

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