Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- CONSTANTS
- local INTERVAL = 120
- local PIPE_SIDE = "bottom"
- local REQUEST_IDS = {
- --Swords
- 267, --Iron
- 268, --Wood
- 272, --Stone
- 276, --Diamond
- 283, --Gold
- 4369, --Quarz
- 5648, --Green Sapphire
- 5649, --Ruby
- 5650, --Blue Sapphire
- 30198, --Bronze
- }
- -- 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
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement