Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local arrayTable = require("array")
- local chests = require("chestList")
- function request(searched, output)
- term.clear()
- term.setCursorPos(1,1)
- local amount
- local its
- for i = 1, #searched do
- if(string.sub(searched, i,i) == " ") then
- amount = string.sub(searched, 1, i - 1)
- its = string.sub(searched, i+1,#searched)
- end
- end
- print("Count:" ..amount .. " Name: " .. its)
- local toTake = arrayTable.new()
- local amountNeeded = amount
- local canStop = false
- for i = 0, chests.size - 1 do
- for slot, item in pairs(chests.list[i].list()) do
- if(item) then
- if(item.name == its) then
- print("Set")
- toTake.set({info = item ,slot = slot , chest = i})
- if(amountNeeded - item.count <= 0) then
- canStop = true
- break
- end
- amountNeeded = amountNeeded - amount
- end
- end
- end
- if(canStop == true) then break end
- end
- for index, item in pairs(toTake.list) do
- if(item.info.count - amount > 0) then
- output.pullItems(peripheral.getName(chests.list[tonumber(item.chest)]),tonumber(item.slot), tonumber(amount))
- break
- else
- output.pullItems(peripheral.getName(chests.list[tonumber(item.chest)]),tonumber(item.slot), tonumber(item.info.count))
- amount = amount - item.info.count
- end
- end
- end
- return request
Advertisement
Add Comment
Please, Sign In to add comment