Advertisement
Guest User

emptySword.lua

a guest
Jun 8th, 2022
35
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.15 KB | None | 0 0
  1. --configuration--
  2. filterItem = "tconstruct:sword"
  3.  
  4.  
  5.  
  6. --software--
  7. local manager = peripheral.find("inventoryManager")
  8. local chest = peripheral.find("blockReader")
  9. if chest == nil then error("Chest is not present") end
  10. if manager == nil then error("Inventory Manager is not present") end
  11. hand = {}
  12. id = ""
  13.  
  14. function removeItem()
  15.     hand = manager.getItemInHand()
  16.     if hand["name"] == filterItem then
  17.         tankCap = hand["nbt"]["tic_volatile_data"]["tconstruct:tank_capacity"]
  18.         --print(tankCap)
  19.         if hand["nbt"]["tic_persistent_data"]["tconstruct:tank_fluid"]["Amount"] >= tankCap then
  20.             manager.removeItemFromPlayer("top", 1, -1, filterItem)
  21.             print("Removed: "..hand["displayName"])
  22.         end
  23.     end
  24. end
  25.  
  26. function returnItem()
  27.     if chest.getBlockData()["Items"][0] ~= nil then
  28.         print("Got Item")
  29.         id = chest.getBlockData()["Items"][0]["id"]
  30.         print(id)
  31.         if id == filterItem then
  32.             print("Trying to insert item")
  33.             manager.addItemToPlayer("top", 1, 5, filterItem)
  34.         end
  35.     end
  36. end
  37.  
  38.  
  39. while true do
  40.  removeItem()
  41.  returnItem()
  42.  sleep(0.2)
  43. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement