Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --# load the touchpoint API
- os.loadAPI("touchpoint")
- --# initialize a new button set on the top monitor
- local monitor = peripheral.wrap("right")
- monitor.setTextScale(.5)
- local t=touchpoint.new("right")
- local commandBlock = peripheral.wrap("bottom")
- local function deckTP(deckNum)
- if deckNum == "E" then
- commandBlock.setCommand("tp @p[r=4] -132 134 388")
- commandBlock.runCommand()
- elseif deckNum == "G" then
- commandBlock.setCommand("tp @p[r=4] -131 179 388")
- commandBlock.runCommand()
- elseif deckNum == "P" then
- commandBlock.setCommand("tp @p[r=4] -131 127 388")
- commandBlock.runCommand()
- elseif deckNum == "Q" then
- commandBlock.setCommand("tp @p[r=4] -131 120 388")
- commandBlock.runCommand()
- elseif deckNum == "R" then
- commandBlock.setCommand("tp @p[r=4] -131 113 388")
- commandBlock.runCommand()
- elseif deckNum == "S" then
- commandBlock.setCommand("tp @p[r=4] -131 106 388")
- commandBlock.runCommand()
- elseif deckNum == "T" then
- commandBlock.setCommand("tp @p[r=4] -131 99 388")
- commandBlock.runCommand()
- else
- term.clear()
- term.setCursorPos(1,1)
- print("Invalid Destination Entered")
- end
- end
- t:add("G Deck",function() deckTP("G") end, 2, 2, 14, 2, colors.red, colors.lime)
- t:add("Engineering",function() deckTP("E") end, 2, 4, 14, 4, colors.red, colors.lime)
- t:add("P Deck",function() deckTP("P") end, 2, 6, 14, 6, colors.red, colors.lime)
- t:add("Q Deck",function() deckTP("Q") end, 2, 8, 14, 8, colors.red, colors.lime)
- t:add("R Deck",function() deckTP("R") end, 2, 10, 14, 10, colors.red, colors.lime)
- t:add("S Deck",function() deckTP("S") end, 2, 12, 14, 12, colors.red, colors.lime)
- t:add("T Deck",function() deckTP("T") end, 2, 14, 14, 14, colors.red, colors.lime)
- local function getdeck()
- term.clear()
- term.setCursorPos(1,1)
- term.write("Turbo Lift")
- print()
- write("Enter Deck Number: ")
- deckTP(read())
- end
- local function buttonPress()
- while true do
- t:draw()
- --# handleEvents will convert monitor_touch events to button_click if it was on a button
- local event, p1 = t:handleEvents(os.pullEvent())
- if event == "button_click" then
- t:flash(p1) --# This will cause it to look green for a second and then back to red
- t.buttonList[p1].func() --# This will call the function in the button, That thing earlier where it says function() deckTP("1") end.
- break
- end
- end
- end
- while true do
- 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.
- --#However we're in a while true loop, which means that it will restart when one finishes :P/>/>/>/>/>/>
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement