tjaccardi

TeleNet0_9

Feb 23rd, 2020 (edited)
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.37 KB | None | 0 0
  1. do
  2. component = require("component")
  3. term = require("term")
  4. table = require("table")
  5. chestapi = require("ChestAPI")
  6. computer = component.computer
  7. rs = component.redstone
  8.  
  9. gpu = component.gpu
  10. gpu.setResolution(80,25)
  11.  
  12. --made by StormWolf (AKA StormCircuit) with help from chummy
  13.  
  14.  
  15. version=00.9
  16.  
  17. term.clear()
  18.  
  19.  
  20. print("StormCircuit's TeleNet selector client version "..tostring(version))
  21. print("\n---------------------------------------------------------------------")
  22. function client ()
  23. do
  24.  
  25. initialize()
  26. inventory = { }
  27. inventory = inventoryScanner(0)
  28.  
  29. --i is starting position for inventory scanner
  30. i=1
  31. while i<=15 do
  32. term.setCursor(1,i+3)
  33. term.clearLine()
  34. if not inventory[i] then
  35. io.write("["..i.."] - No input")
  36. else
  37. io.write("["..i.."] - "..tostring(inventory[i]))
  38. end
  39. i=i+1
  40. end
  41.  
  42. j=1
  43. while i<=30 do
  44. term.setCursor(40,j+3)
  45. if not inventory[i] then
  46. io.write("["..i.."] - No input")
  47. else
  48. io.write("["..i.."] - "..tostring(inventory[i]))
  49. end
  50. i=i+1
  51. j=j+1
  52. end
  53. print("\n-------------------------------------------------------------------")
  54.  
  55. cursorPosition=20
  56. prevlocation=1
  57. while true do
  58. term.setCursor(1,cursorPosition)
  59. term.clearLine()
  60. io.write("Input number for desired location followed by enter: ")
  61. location = io.read()
  62. location = tonumber(location)
  63.  
  64.  
  65.  
  66. if not tonumber(location) then
  67. term.clearLine()
  68. print("Invalid option. Please try again.")
  69. client()
  70. elseif not inventory[location] then
  71. term.clearLine()
  72. print("Invalid option. Please try again.")
  73. client()
  74. elseif tonumber(location)==-1 then
  75. term.clearLine()
  76. print("Reloaded table.")
  77. client()
  78. elseif tonumber(location)<0 then
  79. term.clearLine()
  80. print("Invalid option. Please try again.")
  81. client()
  82. elseif tonumber(location)>0 then
  83. location = tonumber(location)
  84. else
  85. end
  86. --transfer item here
  87. transposer.transferItem(0, 1, 1, location, 1)
  88.  
  89. i=0
  90. while i<2 do
  91. term.setCursor(1,cursorPosition+2)
  92. term.clearLine()
  93. io.write("Loading location... {}")
  94. os.sleep(0.5)
  95. term.setCursor(1,cursorPosition+2)
  96. io.write("Loading location... { }")
  97. computer.beep()
  98. os.sleep(0.5)
  99. term.clearLine()
  100. i=i+1
  101. term.setCursor(1,2)
  102. term.clearLine()
  103. if location then
  104. io.write("Last location entered: "..inventory[location])
  105. end
  106. end
  107. term.setCursor(1,cursorPosition+1)
  108. term.clearLine()
  109.  
  110. term.setCursor(1,cursorPosition+3)
  111. io.write("Initializing teleportation!")
  112. computer.beep()
  113. rs.setOutput(0, 10)
  114. rs.setOutput(0, 0)
  115. os.sleep(2)
  116. term.clearLine()
  117. prevlocation = location
  118. end
  119. end
  120. end
  121.  
  122.  
  123.  
  124.  
  125.  
  126. --Old functions - left here while code is being refactored to use ChestAPI
  127. function inventoryScanner()
  128. local sides = require("sides")
  129. size = chestAccess.getInventorySize(sides.top)
  130. i = 1
  131. while i<size do
  132. item = chestAccess.getStackInSlot(sides.top, i)
  133. if not item then break end
  134. inventory[i] = tostring(item.label)
  135. i=i+1
  136. end
  137. return inventory
  138. end
  139.  
  140.  
  141.  
  142.  
  143.  
  144.  
  145. --actual shit thats executed at instant run:
  146. client()
  147. end
Add Comment
Please, Sign In to add comment