Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- starttime = os.clock()
- local periList = peripheral.getNames()
- local enderTank = nil
- local enderChest = nil
- for i = 1, #periList do
- if peripheral.getType(periList[i]) == "ender_tank" and enderTank == nil then
- enderTank = peripheral.wrap(periList[i])
- print("EnderTank mounted as "..periList[i])
- elseif peripheral.getType(periList[i]) == "ender_chest" and enderChest == nil then
- enderChest = peripheral.wrap(periList[i])
- print("EnderChest mounted as "..periList[i])
- end
- end
- local colorindex = {
- colors.white,
- colors.orange,
- colors.magenta,
- colors.lightBlue,
- colors.yellow,
- colors.lime,
- colors.pink,
- colors.gray,
- colors.lightGray,
- colors.cyan,
- colors.purple,
- colors.blue,
- colors.brown,
- colors.green,
- colors.red,
- colors.black
- }
- local colornames = {
- "White",
- "Orange",
- "Magenta",
- "LightBlue",
- "Yellow",
- "Lime",
- "Pink",
- "Gray",
- "GightGray",
- "Cyan",
- "Purple",
- "Blue",
- "Brown",
- "Green",
- "Red",
- "Black"}
- print("Ready to scan")
- local function setTank(c1,c2,c3)
- -- for some reason, ender tanks set thir colors backwards
- if enderTank ~= nil then enderTank.setColors(c3,c2,c1) end
- end
- local function setChest(c1,c2,c3)
- if enderChest ~= nil then enderChest.setColors(c1,c2,c3) end
- end
- local function tankInfo()
- -- available keys are rawName (localized name), amount (mB), capacity (mB), name (internal name), id (liquid id)
- return enderTank.getTankInfo('')[1]
- end
- -- available keys for chest.getStackInSlot(n) are:
- -- |- name (Sign)
- -- |- rawName (item.sign)
- -- |- id
- -- |- dmg (0)
- -- |- maxSize (16 - max size of stack)
- -- |- ench(table)
- -- Empty for sign
- -- "Efficiency V"
- -- |- qty
- local function niceColorName(a,b,c)
- return colornames[a]..' '..colornames[b]..' '..colornames[c]
- end
- f = fs.open('_tanks','w')
- numcols = 16
- for a = 1, 1 do
- for b = 1, 1 do
- for c = 1, numcols do
- setTank(colorindex[a], colorindex[b], colorindex[c])
- setChest(colorindex[a], colorindex[b], colorindex[c])
- tankData = tankInfo()
- if tankData.rawName ~= nil then
- entry = "Tank "..niceColorName(a,b,c).." contains "..tankData.amount.." mB of "..tankData.rawName
- print(entry)
- f.writeLine(entry)
- end
- chestHasAnything = false
- for invitr = 1, enderChest.getInventorySize() do
- inv = enderChest.getStackInSlot(invitr)
- if inv ~= nil then
- if not chestHasAnything then
- entry = "Chest "..niceColorName(a,b,c).." contains:"
- print(entry)
- f.writeLine(entry)
- -- don't print this message again
- chestHasAnything = true
- end
- entry = "x"..inv.qty.." "..inv.name.."("..inv.id..":"..inv.dmg..")"
- print(entry)
- f.writeLine(entry)
- for k,v in pairs(inv.ench) do
- entry = "|- "..v
- print(entry)
- f.writeLine(entry)
- end
- end
- end
- end
- end
- end
- f.close()
- print(string.format("elapsed time: %.2f\n", os.clock() - starttime))
Advertisement
Add Comment
Please, Sign In to add comment