Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Import Totems of Undying into player inventory slot 40 from chest on top
- local manager = peripheral.find("inventoryManager")
- if not manager then
- error("No inventoryManager peripheral found. Is the manager properly connected and memory card inserted?")
- end
- -- Verify ownership
- local owner = manager.getOwner()
- if not owner or owner ~= os.getComputerLabel() then
- print("WARNING: Inventory Manager has no memory card or owner is different.")
- end
- local CHEST_DIR = "up"
- local SLOT = 40
- local ITEM_NAME = "minecraft:totem_of_undying"
- local function importTotems()
- -- Check if player slot 40 is free (optional)
- if not manager.isSpaceAvailable() then
- print("Player inventory may be full—cannot import.")
- return
- end
- -- Try adding all totems from chest into player's slot 40
- local moved = manager.addItemToPlayer(CHEST_DIR, {
- name = ITEM_NAME,
- toSlot = SLOT,
- count = math.huge -- will import full stack available
- })
- if moved > 0 then
- print(("Imported %d Totem(s) into slot %d"):format(moved, SLOT))
- else
- print("No Totems of Undying found in chest above, or failed to import.")
- end
- end
- -- Run once
- importTotems()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement