Advertisement
fishermedders

EbTeleterminal 2

Oct 29th, 2016
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.16 KB | None | 0 0
  1. books = {{"FloorB","Dense","Clickme","y"},{"testing","TEST","HAI","CLIk"}}
  2. names = {{"BedrockFloor","Dense Ores World","Click Me!","y"},{"testing","TEST","HAI","clickit"}}
  3. xes = {}
  4. max = 4
  5. page = 1
  6.  
  7. function reset()
  8. term.setBackgroundColor(colors.white)
  9. term.setTextColor(colors.black)
  10. term.clear()
  11. end
  12.  
  13. function cprint(w,y,text)
  14. term.setCursorPos((w/2)-(#text/2),y)
  15. term.write(text)
  16. end
  17.  
  18. function getCenter(w,text,reset)
  19. if reset == false then
  20. one = (w/2)-(#text/2)
  21. two = one+#text
  22. tbl = {}
  23. table.insert(tbl,one)
  24. table.insert(tbl,two-1)
  25. table.insert(xes,tbl)
  26. elseif reset == true then
  27. xes = {}
  28. end
  29. end
  30.  
  31. while true do
  32. reset()
  33. term.setBackgroundColor(colors.red)
  34. term.setCursorPos(1,1)
  35. size = {term.getSize()} --term has already been redirected.
  36. for i = 1,size[1] do
  37. term.write(" ")
  38. end
  39. term.setCursorPos(1,size[2])
  40. for i = 1,size[1] do
  41. term.write(" ")
  42. end
  43. term.setCursorPos((size[1]/2)-4,size[2]-2)
  44. term.write(" < ")
  45. term.setCursorPos((size[1]/2)+1,size[2]-2)
  46. term.write(" > ")
  47. cprint(size[1],1,"EBTele Terminal")
  48. term.setBackgroundColor(colors.white)
  49. cprint(size[1],size[2]-1,"Page "..page)
  50. cprint(size[1],3,"Select a Destination")
  51. for i = 1,#books[page] do
  52. term.setBackgroundColor(colors.red)
  53. cpos = {term.getCursorPos()}
  54. cprint(size[1],cpos[2]+2," "..names[page][i].." ")
  55. getCenter(size[1]," "..names[page][i].." ",false)
  56. end
  57.  
  58. evnt = {os.pullEvent()}
  59. if evnt[1] == "mouse_click" then
  60. for i = 1,#books[page] do
  61. if evnt[4] == 3+(2*i) then
  62. if evnt[3] >= xes[i][1] and evnt[3] <= xes[i][2] then
  63. print(names[page][i])
  64. --sleep
  65. end
  66. end
  67. end
  68. if evnt[4] == size[2]-2 then
  69. if evnt[3] >= (size[1]/2)-5 and evnt[3] <= (size[1]/2)-2 then
  70. if page == 1 then
  71. page = #books
  72. else
  73. page = page-1
  74. end
  75. elseif evnt[3] >= (size[1]/2) and evnt[3] <= (size[1]/2)+3 then
  76. if page == #books then
  77. page = 1
  78. else
  79. page = page + 1
  80. end
  81. end
  82. end
  83. end
  84. getCenter(size[1],"na",true)
  85. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement