Advertisement
fishermedders

Elevator

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