tjaccardi

TeleNet0_3

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