Advertisement
cyber_Ahn

Spatial IO Teleporter (Objects and Player)

Jan 9th, 2016
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.12 KB | None | 0 0
  1. --var--
  2. teleporter_num_in = "1"
  3. mon = peripheral.wrap("monitor_13")
  4. CableSide = "right"
  5. tout = peripheral.wrap("powered_tile_30")
  6. tin = peripheral.wrap("powered_tile_29")
  7. plus = 100
  8. power = true
  9.  
  10. --func set tp num--
  11. teleporter_num_in = teleporter_num_in + plus
  12. function set_tp_num()
  13. tin.setFrequency(tonumber(teleporter_num_in))
  14. end
  15. --draw screen--
  16. function display()
  17. set_tp_num()
  18. mon.setBackgroundColor(colors.black)
  19. mon.clear()
  20. mon.setBackgroundColor(colors.red)
  21. mon.setTextColor(colors.black)
  22. mon.setCursorPos(1,1)
  23. mon.write("X")
  24. x,y = mon.getSize()
  25. mon.setBackgroundColor(colors.black)
  26. mon.setTextColor(colors.black)
  27. for i = 1, y, 2 do
  28.   mon.setCursorPos(x/2,i)
  29.   mon.setBackgroundColor(colors.purple)
  30.   mon.write(" "..i.." ")
  31.   mon.setCursorPos(x/2,i+1)
  32.   mon.setBackgroundColor(colors.lightBlue)
  33.   mon.write(" "..(i+1).." ")
  34. end
  35. touch()
  36. end
  37.  
  38. -- function teleport
  39. function teleport(data)
  40. data = data + plus
  41. if teleporter_num_in == data then
  42. mon.setBackgroundColor(colors.red)
  43. mon.clear()
  44. mon.setCursorPos(2,1)
  45. mon.write("Can't")
  46. mon.setCursorPos(3,2)
  47. mon.write("TP")
  48. mon.setCursorPos(1,3)
  49. mon.write("to me !")
  50. sleep(5)
  51. else
  52. mon.setBackgroundColor(colors.blue)
  53. mon.clear()
  54. mon.setCursorPos(1,1)
  55. mon.write("Telepor")
  56. mon.setCursorPos(3,2)
  57. mon.write("to")
  58. mon.setCursorPos(4,3)
  59. mon.write(data)
  60. tout.setFrequency(tonumber(data))
  61. rs.setBundledOutput(CableSide,colors.white) -- move cell and set pipe out for income off
  62. sleep(5)
  63. rs.setBundledOutput(CableSide,colors.black) -- off
  64. sleep(8)
  65. rs.setBundledOutput(CableSide,colors.blue) -- impulse load
  66. sleep(2)
  67. rs.setBundledOutput(CableSide,colors.orange) -- start tp and pipe to tess.
  68. sleep(10)
  69. rs.setBundledOutput(CableSide,colors.black) -- off
  70. sleep(1)
  71. end
  72. if power == true then
  73. display()
  74. end
  75. end
  76.  
  77. -- func touch--
  78. function touch()
  79. input = false
  80. while input == false do
  81. event,side,x,y = os.pullEvent()
  82. if event == "monitor_touch" then
  83. if x == 1 and y == 1 then
  84. mon.setBackgroundColor(colors.black)
  85. mon.clear()
  86. shell.run("shutdown")
  87. else
  88. input = true
  89. dest = string.sub(y,1,1)
  90. teleport(dest)
  91. end
  92. end
  93. end
  94. end
  95.  
  96. --program--
  97. display()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement