Advertisement
thatparadox

Spatial Teleport v2

Apr 30th, 2015
414
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.45 KB | None | 0 0
  1. mon = peripheral.find("monitor")
  2.  
  3. freqRange = 60
  4.  
  5. ECInput = peripheral.wrap("top")
  6. ECOutput = peripheral.wrap("bottom")
  7. ioPort = peripheral.wrap("right")
  8.  
  9. function drawBackground()
  10.   mon.setBackgroundColor(colors.black)
  11.   mon.clear()
  12.   x,y = mon.getSize()
  13.   for yc = 1,y do
  14.     if yc%2 == 1 then
  15.       mon.setBackgroundColor(colors.purple)
  16.     else
  17.       mon.setBackgroundColor(colors.magenta)
  18.     end
  19.     for xc = 1,x do
  20.       mon.setCursorPos(xc, yc)
  21.       mon.write(" ")
  22.     end
  23.   end
  24. end
  25.  
  26. function inputPage(level)
  27.   mon.clear()
  28.   mon.setBackgroundColor(colors.pink)
  29.   mon.setCursorPos(1, 1)
  30.   mon.write("go to")
  31.   mon.setCursorPos(1, 2)
  32.   mon.write("computer")
  33.   term.clear()
  34.   x,y = term.getSize()
  35.   term.setCursorPos(x/2-8, y/2-2)
  36.   print("Enter Name")
  37.   term.setCursorPos(2, y/2)
  38.   print("        ")
  39.   term.setCursorPos(2, y/2)
  40.   label = read()
  41.   term.setBackgroundColor(colors.black)
  42.   term.clear()
  43.   file = fs.open(tostring(param3), "w")
  44.   file.write(label)
  45.   file.close()
  46. end
  47.  
  48. function drawButtons()
  49.   x,y = mon.getSize()
  50.   for i=1,y do
  51.     if fs.exists(tostring(i)) then
  52.       file = fs.open(tostring(i), "r")
  53.       label = file.readAll()
  54.       file.close()
  55.       mon.setCursorPos(x/2 - string.len(label)/2, i)
  56.       if i%2 == 1 then
  57.         mon.setBackgroundColor(colors.purple)
  58.       else
  59.         mon.setBackgroundColor(colors.magenta)
  60.       end
  61.       mon.setTextColor(colors.white)
  62.       mon.write(label)
  63.       mon.setCursorPos(x, i)
  64.       mon.setBackgroundColor(colors.black)
  65.       mon.setTextColor(colors.white)
  66.       mon.write("X")
  67.     end
  68.   end
  69. end
  70.  
  71. if fs.exists("freq") then
  72.   file = fs.open("freq", "r")
  73.   freq = file.readAll()
  74.   file.close()
  75. else
  76.   mon.clear()
  77.   mon.setCursorPos(1,1)
  78.   mon.write("GO TO")
  79.   mon.setCursorPos(1,1)
  80.   mon.write("COMPUTER")
  81.   term.clear()
  82.   term.setCursorPos(1,1)
  83.   print("Enter a unique number for where you want this pad to appear on the touchscreen. 1 is the top of the screen:")
  84.   write("> ")
  85.   freq = read()
  86.   file = fs.open("freq", "w")
  87.   file.write(freq)
  88.   file.close()
  89. end
  90. if fs.exists("incCheck") == false then
  91.   shell.run("pastebin get kSr7S9ym incCheck")
  92. end
  93.  
  94. ECInput.setFrequency(freq + freqRange)
  95. ECOutput.setFrequency(freqRange)
  96.  
  97. shell.openTab("incCheck")
  98. while true do
  99.   x,y=mon.getSize()
  100.   mon.clear()
  101.   drawBackground()
  102.   drawButtons()
  103.   event, param1, param2, param3 = os.pullEvent("monitor_touch")
  104.   if param2 < x then
  105.     if fs.exists(tostring(param3)) then
  106.       ECInput.setFrequency(freqRange)
  107.       ECOutput.setFrequency(param3 + freqRange)
  108.       if ECInput.pushItem("East",1) == 1 then
  109.         rs.setOutput("back", true)
  110.         sleep(3)
  111.         rs.setOutput("back", false)
  112.         var = ioPort.getStackInSlot(1)
  113.         while var == nil do
  114.             sleep(0.1)
  115.             var = ioPort.getStackInSlot(1)
  116.         end
  117.         var = ioPort.getStackInSlot(2)
  118.         while var == nil do
  119.             rs.setAnalogOutput("right", 1)
  120.             sleep(0.5)
  121.             rs.setOutput("right", false)
  122.             var = ioPort.getStackInSlot(2)
  123.         end
  124.         ioPort.pushItem("down", 2)
  125.         rs.setOutput("right", false)
  126.         rs.setOutput("back", false)
  127.         ECInput.setFrequency(freqRange + freq)
  128.       else
  129.         mon.clear()
  130.         mon.setCursorPos(1,1)
  131.         mon.write("No Drive")
  132.         sleep(1)
  133.       end
  134.     else
  135.       inputPage(param3)
  136.     end
  137.   else
  138.     fs.delete(tostring(param3))
  139.   end
  140. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement