tjaccardi

TeleNet0_5

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