Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local function transfer(self, destination, name, count)
- if not count then count = 64 end
- local countLeft = count
- for slot, item in pairs(self.peripheral.list()) do
- if item.name == name then
- countLeft = countLeft - self.peripheral.pushItems(destination, slot, countLeft)
- if countLeft < 1 then break end
- end
- end
- end
- local function list(self)
- local results = {}
- for slot, item in pairs(self.peripheral.list()) do
- if results[item.name] ~= nil then
- results[item.name] = results[item.name] + item.count
- else
- results[item.name] = item.count
- end
- end
- return results
- end
- local function amount(self, name)
- local results = 0
- for slot, item in pairs(self.peripheral.list()) do
- if item.name == name then
- results = results + item.count
- end
- end
- return results
- end
- local function make(peripheral)
- return {
- peripheral = peripheral,
- transfer = transfer,
- list = list,
- amount = amount
- }
- end
- return { make = make }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement