tjaccardi

TeleNet0_8

Mar 30th, 2019
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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 with help from chummy, for any non-profit use only
  13.  
  14.  
  15. version=00.8
  16.  
  17. term.clear()
  18.  
  19.  
  20. print("StormWolf'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.     print("Input number for desired location followed by enter")
  60.     term.clearLine()
  61.     io.write("or enter 0 to select last location: ")
  62.     location = io.read()
  63.      
  64.     if tonumber(location)>getMaxSize(1) then
  65.       term.clearLine()
  66.       print("Invalid option. Please try again.")
  67.       client()
  68.     elseif not tonumber(location) then
  69.       client()    
  70.     elseif tonumber(location)==-1 then
  71.       term.clearLine()
  72.       print("Reloaded table.")
  73.       client()
  74.     elseif tonumber(location)<0 then
  75.       term.clearLine()
  76.       print("Invalid option. Please try again.")
  77.       client()
  78.     elseif tonumber(location)==0 then
  79.       location = prevlocation
  80.     elseif tonumber(location)>0 then
  81.       location = tonumber(location)
  82.     else
  83.       term.clearLine()
  84.       print("Invalid option. Please try again.")
  85.       client()
  86.       end
  87.      
  88.     --transfer item here
  89.     transposer.transferItem(0, 1, 1, location, 1)
  90.        
  91.     i=0
  92.     while i<2 do
  93.       term.setCursor(1,cursorPosition+2)
  94.       term.clearLine()
  95.       io.write("Loading location... {}")
  96.       os.sleep(0.5)
  97.       term.setCursor(1,cursorPosition+2)
  98.       io.write("Loading location... { }")
  99.       computer.beep()
  100.       os.sleep(0.5)
  101.       term.clearLine()
  102.       i=i+1
  103.       term.setCursor(1,2)
  104.       term.clearLine()
  105.       if location then
  106.         io.write("Last location entered: "..inventory[location])
  107.         end
  108.       end
  109.     term.setCursor(1,cursorPosition+1)
  110.     term.clearLine()
  111.  
  112.     term.setCursor(1,cursorPosition+3)
  113.     io.write("Initializing teleportation!")
  114.     computer.beep()
  115.     rs.setOutput(0, 10)
  116.     rs.setOutput(0, 0)
  117.     os.sleep(2)
  118.     term.clearLine()
  119.     prevlocation = location
  120.     end
  121.   end  
  122.   end
  123.  
  124.  
  125.  
  126.  
  127.  
  128. --Old functions - left here while code is being refactored to use ChestAPI
  129. function inventoryScanner()
  130.   local sides = require("sides")
  131.   size = chestAccess.getInventorySize(sides.top)
  132.   i = 1
  133.   while i<size do
  134.       item = chestAccess.getStackInSlot(sides.top, i)
  135.       if not item then break end
  136.       inventory[i] = tostring(item.label)
  137.       i=i+1
  138.     end
  139.   return inventory
  140. end
  141.  
  142.  
  143.  
  144.  
  145.  
  146.  
  147. --actual shit thats executed at instant run:
  148. client()
  149. end
Advertisement
Add Comment
Please, Sign In to add comment