Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- CONSTANTS
- local INTERVAL = 5
- local PIPE_SIDE = "bottom"
- local REQUEST_IDS = {
- --Bow
- 261,
- 352,
- 262,
- 397,
- 367,
- 391,
- 341,
- 287,
- 262,
- 267,
- 256,
- 272,
- 298,
- 299,
- 300,
- 301,
- 302,
- 303,
- 304,
- 305,
- }
- -- IMPLEMENTATION
- function convertNBT(nbt)
- local conv = {}
- if (nbt == nil) then
- return nil
- elseif (nbt["type"] == "NBTTagCompound") or (nbt["type"] == "NBTTagList") then
- for key, value in pairs(nbt["value"]) do
- conv[key] = convertNBT(value)
- end
- else
- conv = nbt["value"]
- end
- return conv
- end
- function getItems(pipe)
- pipe.getAvailableItems()
- local event, result = os.pullEvent("available_items_return")
- return result
- end
- function inList(item)
- for _, id in pairs(REQUEST_IDS) do
- if item.id == id then
- return true
- end
- end
- return false
- end
- -- MAIN
- local pipe = peripheral.wrap(PIPE_SIDE)
- while true do
- for i, result in pairs(getItems(pipe)) do
- local iid, amount = unpack(result)
- local item = {
- id = pipe.getItemID(iid),
- dmg = pipe.getItemDamage(iid),
- nbt = convertNBT(pipe.getNBTTagCompound(iid))
- }
- if inList(item) then
- pipe.makeRequest(iid, amount)
- sleep(2)
- end
- end
- sleep(INTERVAL)
- end
Add Comment
Please, Sign In to add comment