Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- pimside = "left"
- chestdir = "down"
- redstoneside = "back"
- senseside = "right"
- safenames = {"agichobo15", "bagofdoritos"}
- transside = "top"
- transchest = "up"
- gateside = "front"
- opsleeptime = 1
- term.clear()
- term.setCursorPos(1,1)
- pim = peripheral.wrap(pimside)
- trans = peripheral.wrap(transside)
- redstone.setOutput(gateside, true)
- function search(ar, sear)
- for i = 1, #ar do
- if sear == ar[i] then
- return true
- end
- end
- return false
- end
- function opisnearby(tab)
- for i, s in pairs(tab) do
- if search(safenames, s.name) == true then
- return true
- end
- end
- return false
- end
- function checksafe()
- tab = peripheral.call(senseside, "getPlayers")
- return not opisnearby(tab)
- end
- function suckallitems(size)
- print("sucking items")
- for i=1,size do
- pim.pushItem(chestdir, i)
- end
- end
- function toggletransport()
- print("toggling warp")
- if trans.getStackInSlot(1) == none then
- trans.pullItem(transchest, 1)
- else
- trans.pushItem(transchest, 1)
- end
- end
- function waitforredstone()
- while redstone.getInput(redstoneside) == false do
- os.pullEvent("redstone")
- end
- end
- function run()
- while true do
- redstone.setOutput(gateside, true)
- waitforredstone()
- s = pim.getInventorySize()
- if s > 1 then
- if redstone.getInput(redstoneside) == true then
- if checksafe() == true then
- suckallitems(s)
- toggletransport()
- sleep(1)
- toggletransport()
- else
- print("op detected. canceling suck.")
- redstone.setOutput(gateside, false)
- sleep(opsleeptime)
- end
- end
- end
- end
- end
- run()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement