Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- pushTest.lua
- -- 1) Find all adjacent chests
- local chests = { peripheral.find("minecraft:chest") }
- if #chests < 2 then
- print("❌ Need at least two chests attached to test pushItems")
- return
- end
- -- 2) Pick the first two
- local chestA = chests[1]
- local chestB = chests[2]
- local nameA = peripheral.getName(chestA)
- local nameB = peripheral.getName(chestB)
- print(("Testing push from %q → %q"):format(nameA, nameB))
- -- 3) Verify pushItems exists
- local methodsA = peripheral.getMethods(nameA)
- local hasPush = false
- for _, m in ipairs(methodsA) do
- if m == "pushItems" then hasPush = true break end
- end
- if not hasPush then
- print("⚠️ pushItems not supported on this chest peripheral.")
- return
- end
- -- 4) Attempt to move one item from slot 1
- -- This will throw an error if something’s wrong
- local moved = chestA.pushItems(nameB, 1, 1)
- if moved == 0 then
- print("ℹ️ pushItems succeeded but moved 0 items (slot 1 empty?)")
- else
- print(("✅ pushItems moved %d item(s) from slot 1"):format(moved))
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement