tjaccardi

TeleNet0_51

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