fishermedders

nnn

Dec 14th, 2019
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.25 KB | None | 0 0
  1. oMonitor = peripheral.wrap("monitor_10")
  2. oChest = peripheral.wrap("top")
  3.  
  4. tColors = {
  5. ["bg"]=colors.white, -- background color
  6. ["tc"]=colors.black, -- text color
  7. ["fg"]=colors.lightBlue, -- foreground color
  8. ["vc"]=colors.blue, -- vanity color
  9. ["rc"]=colors.lightGray, -- row color
  10. }
  11. tDestinations = {
  12. "house1",
  13. "big house",
  14. "meem",
  15. "hihi",
  16. "big moose statue",
  17. "big moose statue",
  18. "big moose statue",
  19. "frick frack frock nutkc rjif",
  20. "big moose statue",
  21. "big moose statue",
  22. "big moose statue",
  23. "big moose statue",
  24. "big moose statue",
  25. "big moose statue",
  26. "big moose statue",
  27. "big moose statue",
  28. "big moose statue",
  29. "big moose statue",
  30. "big moose statue",
  31. "big moose statue",
  32. "big moose statue",
  33. "big moose statue",
  34. "big moose statue",
  35. "big moose statue",
  36. "big moose statue",
  37. "big moose statue",
  38. "big moose statue",
  39. "big moose statue",
  40. "big moose statue",
  41. "big moose statue",
  42. }
  43.  
  44. function fCenterPrint(sText, iY)
  45. local tSize = {term.getSize()}
  46. term.setCursorPos((tSize[1]/2)-(#sText/2)+1, iY)
  47. term.write(sText)
  48. end
  49.  
  50. function fDrawLine(iY)
  51. local tSize = {term.getSize()}
  52. term.setCursorPos(1, iY)
  53. for i = 1,tSize[1] do
  54. term.write(" ")
  55. end
  56. end
  57.  
  58. function fDrawSpecLine(iX, iXb, iY)
  59. term.setCursorPos(iX, iY)
  60. for i = iX, iXb do
  61. term.write(" ")
  62. end
  63. end
  64.  
  65. function fDrawBottomLine(iY)
  66. term.setBackgroundColor(tColors.fg)
  67. fDrawLine(iY)
  68. term.setBackgroundColor(tColors.bg)
  69. end
  70.  
  71. function fDrawTextLine(sText, iY)
  72. fDrawBottomLine(iY)
  73. term.setBackgroundColor(tColors.fg)
  74. fCenterPrint(sText, iY)
  75. term.setBackgroundColor(tColors.bg)
  76. end
  77.  
  78. function fDrawDivider(iY, iYb)
  79. term.setBackgroundColor(tColors.fg)
  80. local tSize = {term.getSize()}
  81. for i = iY, iYb do
  82. term.setCursorPos(tSize[1]/2, i)
  83. term.write(" ")
  84. end
  85. end
  86.  
  87. function fDrawVerticalLine(iX, iY, iYb)
  88. term.setBackgroundColor(tColors.fg)
  89. local tSize = {term.getSize()}
  90. for i = iY, iYb do
  91. term.setCursorPos(iX, i)
  92. term.write(" ")
  93. end
  94. end
  95.  
  96. function fFormatTextLen(sText)
  97. local tSize = {term.getSize()}
  98. local iLen = (tSize[1]/2)-4
  99. if #sText > iLen then
  100. sText = string.sub(sText, 1, iLen-3)
  101. sText = sText .. "..."
  102. end
  103. return sText
  104. end
  105.  
  106. function fGetAmountPerPage()
  107. local tSize = {term.getSize()}
  108. return (tSize[2]-2)*2
  109. end
  110.  
  111. function fGetDividerPos()
  112. local tSize = {term.getSize()}
  113. return tSize[1]/2
  114. end
  115.  
  116. iCurrent = -1
  117. while true do
  118. term.setBackgroundColor(tColors.bg)
  119. term.setTextColor(tColors.tc)
  120. term.clear()
  121. tSize = {term.getSize()}
  122. for i = 1,#tDestinations do
  123. if i <= (fGetAmountPerPage()/2) then
  124. if i % 2 == 0 then
  125. term.setBackgroundColor(tColors.rc)
  126. else
  127. term.setBackgroundColor(tColors.bg)
  128. end
  129. end
  130. if i >= (fGetAmountPerPage()/2)+1 then
  131. if i % 2 == 0 then
  132. term.setBackgroundColor(tColors.bg)
  133. else
  134. term.setBackgroundColor(tColors.rc)
  135. end
  136. end
  137. fDrawLine(i+1)
  138. if iCurrent == i then
  139. term.setBackgroundColor(tColors.vc)
  140. end
  141. --fDrawLine(i+1)
  142. if iCurrent <= (fGetAmountPerPage()/2) then
  143. fDrawSpecLine(2, fGetDividerPos()-1,i+1)
  144. end
  145. if iCurrent >= (fGetAmountPerPage()/2)+1 then
  146. fDrawSpecLine(fGetDividerPos()+1, tSize[1],(1+i)-(fGetAmountPerPage()/2))
  147. end
  148. --fDrawLine(i+1)
  149. if i <= (fGetAmountPerPage()/2) then
  150. term.setCursorPos(3,1+i)
  151. end
  152. if i >= (fGetAmountPerPage()/2)+1 then
  153. term.setCursorPos(fGetDividerPos()+2,(1+i)-(fGetAmountPerPage()/2))
  154. end
  155. term.write(fFormatTextLen(i .. ". " .. tDestinations[i]))
  156. end
  157. fDrawTextLine("Select your destination!", 1)
  158. fDrawTextLine("Click here to lock in your selection.", tSize[2])
  159. fDrawDivider(2, tSize[2]-1)
  160. fDrawVerticalLine(1, 2, tSize[2]-1)
  161. fDrawVerticalLine(tSize[1], 2, tSize[2]-1)
  162. term.setCursorPos(1,1)
  163. print(iCurrent)
  164. tEvent = {os.pullEvent()}
  165. if tEvent[1] == "mouse_click" or tEvent[1] == "monitor_touch" then
  166. if tEvent[4] > 1 and tEvent[4] < tSize[2] then
  167. if tEvent[3] < fGetDividerPos() then
  168. iCurrent = tEvent[4]-1
  169. else
  170. iCurrent = (tEvent[4]-1)+(fGetAmountPerPage()/2)
  171. end
  172. end
  173. end
  174. end
Advertisement
Add Comment
Please, Sign In to add comment