Advertisement
Guest User

Turbo

a guest
Mar 31st, 2015
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.88 KB | None | 0 0
  1. --# load the touchpoint API
  2. os.loadAPI("touchpoint")
  3.  
  4. --# initialize a new button set on the top monitor
  5. local monitor = peripheral.wrap("right")
  6. monitor.setTextScale(.5)
  7. local t=touchpoint.new("right")
  8. local commandBlock = peripheral.wrap("bottom")
  9.  
  10. local function deckTP(deckNum)
  11.   if deckNum == "E" then
  12.         commandBlock.setCommand("tp @p[r=4] -132 134 388")
  13.         commandBlock.runCommand()
  14.   elseif deckNum == "G" then
  15.         commandBlock.setCommand("tp @p[r=4] -131 179 388")
  16.         commandBlock.runCommand()
  17.   elseif deckNum == "P" then
  18.         commandBlock.setCommand("tp @p[r=4] -131 127 388")
  19.         commandBlock.runCommand()
  20.   elseif deckNum == "Q" then
  21.         commandBlock.setCommand("tp @p[r=4] -131 120 388")
  22.         commandBlock.runCommand()
  23.   elseif deckNum == "R" then
  24.         commandBlock.setCommand("tp @p[r=4] -131 113 388")
  25.         commandBlock.runCommand()
  26.   elseif deckNum == "S" then
  27.         commandBlock.setCommand("tp @p[r=4] -131 106 388")  
  28.         commandBlock.runCommand()
  29.   elseif deckNum == "T" then
  30.         commandBlock.setCommand("tp @p[r=4] -131 99 388")
  31.         commandBlock.runCommand()        
  32.                              
  33.  else
  34.        term.clear()
  35.        term.setCursorPos(1,1)
  36.        print("Invalid Destination Entered")
  37.   end
  38.   end
  39.  
  40.  t:add("G Deck",function() deckTP("G") end, 2, 2, 14, 2, colors.red, colors.lime)  
  41.  t:add("Engineering",function() deckTP("E") end, 2, 4, 14, 4, colors.red, colors.lime)  
  42.  t:add("P Deck",function() deckTP("P") end, 2, 6, 14, 6, colors.red, colors.lime)
  43.  t:add("Q Deck",function() deckTP("Q") end, 2, 8, 14, 8, colors.red, colors.lime)
  44.  t:add("R Deck",function() deckTP("R") end, 2, 10, 14, 10, colors.red, colors.lime)
  45.  t:add("S Deck",function() deckTP("S") end, 2, 12, 14, 12, colors.red, colors.lime)
  46.  t:add("T Deck",function() deckTP("T") end, 2, 14, 14, 14, colors.red, colors.lime)
  47.  
  48. local function getdeck()
  49.   term.clear()
  50.   term.setCursorPos(1,1)
  51.   term.write("Turbo Lift")
  52.   print()
  53.   write("Enter Deck Number: ")
  54.   deckTP(read())
  55. end
  56. local function buttonPress()
  57.   while true do
  58.     t:draw()
  59.     --# handleEvents will convert monitor_touch events to button_click if it was on a button
  60.           local event, p1 = t:handleEvents(os.pullEvent())
  61.           if event == "button_click" then
  62.                 t:flash(p1) --# This will cause it to look green for a second and then back to red
  63.                 t.buttonList[p1].func() --# This will call the function in the button, That thing earlier where it says function() deckTP("1") end.
  64.                 break
  65.         end
  66.   end
  67. end
  68. while true do
  69.   parallel.waitForAny(buttonPress,getdeck) --#it runs both of the functions, please note the lack of () next to the function names. and will continue on whenever one of them ends.
  70.   --#However we're in a while true loop, which means that it will restart when one finishes :P/>/>/>/>/>/>
  71. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement