Progig01

sManager

Sep 29th, 2020
675
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local storage = require("storag2")
  2. local network = peripheral.wrap("right")
  3. local outputInv = "minecraft:chest_3"
  4.  
  5. myStorage = storage:newStorage(network)
  6. myStorage:init()
  7.  
  8. function stringSplit(input, sep)
  9.     if sep == nil then sep = "%s" end
  10.  
  11.     local t = {}
  12.     for str in string.gmatch(input, "([^"..sep.."]+)") do
  13.         table.insert(t, str)
  14.     end
  15.     return t
  16. end
  17.  
  18. function clearTerm()
  19.     term.clear()
  20.     term.setCursorPos(1,1)
  21. end
  22.  
  23. local termInput = nil
  24. local sTermInput = nil
  25. local itemName = ""
  26. local command = ""
  27. local amount = 0
  28.  
  29. while true do
  30.  
  31.     itemName = ""
  32.     command = ""
  33.     amount = 0
  34.  
  35.     clearTerm()
  36.     termInput = io.read()
  37.     sTermInput = stringSplit(termInput)
  38.  
  39.     for i=1, #sTermInput do
  40.         if i==1 then
  41.             command = sTermInput[i]
  42.         elseif tonumber(sTermInput[i]) == nil then
  43.  
  44.             if itemName == "" then
  45.                 itemName = sTermInput[i]
  46.             else
  47.                 itemName = itemName .. " " .. sTermInput[i]
  48.             end
  49.         else
  50.             amount = sTermInput[i]
  51.         end
  52.     end
  53.  
  54.     if command == "get" then
  55.         myStorage:moveItemTo(outputInv, itemName, tonumber(amount))
  56.     end
  57.  
  58. end
RAW Paste Data