Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local source = "back" -- single-slot inventory
- local target = "bottom" -- destination chest
- local slot = 1
- local waitTime = 0.1
- local owedDrop = false
- local function isSlotEmpty()
- local item = peripheral.call(source, "getItemDetail", slot)
- return item == nil
- end
- local function tryDrop()
- local moved = peripheral.call(source, "pushItems", target, slot, 1)
- if moved > 0 then
- print("Dropped 1 item.")
- return true
- else
- print("Nothing to drop or move failed.")
- return false
- end
- end
- local function waitForNoSignal()
- while redstone.getInput("top") do
- sleep(waitTime)
- end
- end
- local function waitForSignal()
- while not redstone.getInput("top") do
- sleep(waitTime)
- end
- end
- while true do
- waitForNoSignal()
- if not tryDrop() then
- print("Empty inventory — drop owed on reset.")
- owedDrop = true
- end
- waitForSignal()
- if owedDrop then
- print("Reset signal received. Performing owed drop...")
- while not tryDrop() do
- print("Still waiting for item to drop...")
- sleep(1)
- end
- owedDrop = false
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment