SHOW:
|
|
- or go back to the newest paste.
| 1 | m = peripheral.wrap("monitor_1")
| |
| 2 | ||
| 3 | m.setCursorBlink(false) | |
| 4 | m.setBackgroundColor(colors.black) | |
| 5 | - | m.setForegroundColor(colors.white) |
| 5 | + | m.setTextColor(colors.white) |
| 6 | m.setTextScale(.5) | |
| 7 | - | mW,mH = m.size() |
| 7 | + | |
| 8 | mW,mH = m.getSize() | |
| 9 | ||
| 10 | local storage = {}
| |
| 11 | - | local function setFC(c) m.setForegroundColor(c) end |
| 11 | + | |
| 12 | local function setFC(c) m.setTextColor(c) end | |
| 13 | local function setBC(c) m.setBackgroundColor(c) end | |
| 14 | - | print("Reading storage containers from 'storage.list'..."
|
| 14 | + | |
| 15 | - | for s in io.lines("storage.list") do
|
| 15 | + | print("Reading storage containers from 'storage.list'...")
|
| 16 | for s in io.lines("/disk/storage.list") do
| |
| 17 | print("Registering storage "..s.."...")
| |
| 18 | table.insert(storage,peripheral.wrap(s)) | |
| 19 | end | |
| 20 | print("DONE! Initializing...")
| |
| 21 | ||
| 22 | function readStorageData() | |
| 23 | local items = {}
| |
| 24 | - | for i,v n pairs(p.list()) do |
| 24 | + | |
| 25 | for i,v in pairs(p.list()) do | |
| 26 | items[v.name] = (items[v.name] or 0) + v.count | |
| 27 | end | |
| 28 | end | |
| 29 | return items | |
| 30 | end | |
| 31 | ||
| 32 | function updateDisplay() | |
| 33 | m.setCursorPos(1,mH) | |
| 34 | setFC(colors.white) | |
| 35 | m.write("Reloading item data...")
| |
| 36 | local items = readStorageData() | |
| 37 | m.clear() | |
| 38 | m.setCursorPos(1,1) | |
| 39 | m.write("ITEM INVENTORY")
| |
| 40 | m.setCursorPos(1,3) | |
| 41 | setFC(colors.orange) | |
| 42 | m.write("COPPER")
| |
| 43 | - | m.setFC(colors.white) |
| 43 | + | |
| 44 | setFC(colors.white) | |
| 45 | m.write("IRON")
| |
| 46 | m.setCursorPos(1,5) | |
| 47 | setFC(colors.yellow) | |
| 48 | m.write("GOLD")
| |
| 49 | m.setCursorPos(1,6) | |
| 50 | setFC(colors.red) | |
| 51 | m.write("REDSTONE")
| |
| 52 | m.setCursorPos(1,7) | |
| 53 | setFC(colors.gray) | |
| 54 | m.write("COAL")
| |
| 55 | m.setCursorPos(1,8) | |
| 56 | setFC(colors.blue) | |
| 57 | m.write("LAPIS")
| |
| 58 | m.setCursorPos(1,9) | |
| 59 | setFC(colors.lightBlue) | |
| 60 | m.write("DIAMONDS")
| |
| 61 | setFC(colors.white) | |
| 62 | m.setCursorPos(10,3) | |
| 63 | m.write(tostring(items["minecraft:copper_ingot"]or 0)) | |
| 64 | m.setCursorPos(10,4) | |
| 65 | m.write(tostring(items["minecraft:iron_ingot"]or 0)) | |
| 66 | m.setCursorPos(10,5) | |
| 67 | m.write(tostring(items["minecraft:gold_ingot"]or 0)) | |
| 68 | m.setCursorPos(10,6) | |
| 69 | m.write(tostring(items["minecraft:redstone"]or 0)) | |
| 70 | m.setCursorPos(10,7) | |
| 71 | m.write(tostring(items["minecraft:coal"]or 0)) | |
| 72 | m.setCursorPos(10,8) | |
| 73 | m.write(tostring(items["minecraft:lapis_lazuli"]or 0)) | |
| 74 | m.setCursorPos(10,9) | |
| 75 | m.write(tostring(items["minecraft:diamond"]or 0)) | |
| 76 | end | |
| 77 | ||
| 78 | sleep(1) | |
| 79 | while true do | |
| 80 | updateDisplay() | |
| 81 | sleep(10) | |
| 82 | end |