tjaccardi

TeleNet0_4

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