Advertisement
ecco7777

CC Advanced Peripherals Totem Supplier

Jun 22nd, 2025 (edited)
422
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.18 KB | None | 0 0
  1. -- Import Totems of Undying into player inventory slot 40 from chest on top
  2. local manager = peripheral.find("inventoryManager")
  3. if not manager then
  4.   error("No inventoryManager peripheral found. Is the manager properly connected and memory card inserted?")
  5. end
  6.  
  7. -- Verify ownership
  8. local owner = manager.getOwner()
  9. if not owner or owner ~= os.getComputerLabel() then
  10.   print("WARNING: Inventory Manager has no memory card or owner is different.")
  11. end
  12.  
  13. local CHEST_DIR = "up"
  14. local SLOT = 40
  15. local ITEM_NAME = "minecraft:totem_of_undying"
  16.  
  17. local function importTotems()
  18.   -- Check if player slot 40 is free (optional)
  19.   if not manager.isSpaceAvailable() then
  20.     print("Player inventory may be full—cannot import.")
  21.     return
  22.   end
  23.  
  24.   -- Try adding all totems from chest into player's slot 40
  25.   local moved = manager.addItemToPlayer(CHEST_DIR, {
  26.     name = ITEM_NAME,
  27.     toSlot = SLOT,
  28.     count = math.huge  -- will import full stack available
  29.   })
  30.  
  31.   if moved > 0 then
  32.     print(("Imported %d Totem(s) into slot %d"):format(moved, SLOT))
  33.   else
  34.     print("No Totems of Undying found in chest above, or failed to import.")
  35.   end
  36. end
  37.  
  38. -- Run once
  39. importTotems()
  40.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement