paramus

Remote inventory [AP]

Aug 18th, 2025 (edited)
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.12 KB | Gaming | 0 0
  1. local manager = peripheral.wrap("back")
  2. local chatBox = peripheral.wrap("left")
  3. local user = "Paramus200"
  4.  
  5. function Info(item)
  6.     --TODO
  7.     return "TODO"
  8. end
  9.  
  10. function Export(item, qty)
  11.     return manager.addItemToPlayer("up", {name=item, count=qty})
  12. end
  13.  
  14. function Insert(item, qty)
  15.     return manager.removeItemFromPlayer("up", {name=item, count=qty})
  16. end
  17.  
  18. function Request(query)
  19.     local method, item, quantity
  20.     for k, v in string.gmatch(query, "(%w+) (%w+)") do
  21.         if (method == nil) then
  22.             method = v
  23.         elseif (item == nil) then
  24.             item = v
  25.         elseif (quantity == nil) then
  26.             quantity =tonumber(v)
  27.         end
  28.     end
  29.    
  30.     if (method == "i") then
  31.         chatBox.sendMessageToPlayer(Insert(item, quantity), user)
  32.     elseif (method == "e") then
  33.         chatBox.sendMessageToPlayer(Export(item, quantity), user)
  34.     elseif (method == "info") then
  35.         chatBox.sendMessageToPlayer(Info(item), user)
  36.     end
  37. end
  38.  
  39. while(true) do
  40.     local event, username, message, uuid, isHidden = os.pullEvent("chat")
  41.     if (username == user) then
  42.         request(message)
  43.     end
  44. end
Advertisement
Add Comment
Please, Sign In to add comment