Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local itemMonitor = peripheral.wrap("monitor_3")
- local craftingMonitor = peripheral.wrap("monitor_4")
- local meAccess = peripheral.wrap("left")
- local meMonitor = peripheral.wrap("right")
- local monitor_MaxY = 50
- local monitor_MinY = 1
- local monitor_X_Scale = 50
- local monitorX = 1
- local monitorY = monitor_MinY
- local AEItems = {}
- local watchItems = { ores={"Cobblestone","Obsidian","Ore"},
- ingots={"Ingot"}
- }
- -- id, name, rawName, dmg, maxSize, ench, qty
- -- containsItemType, countOfItemType, getAvailableItems
- function spairs(t, order)
- local keys = {}
- for k in pairs(t) do keys[#keys+1] = k end
- if order then
- table.sort(keys, function(a,b) return order(t, a, b) end)
- else
- table.sort(keys)
- end
- local i = 0
- return function()
- i = i + 1
- if keys[i] then
- return keys[i], t[keys[i]]
- end
- end
- end
- function Load_FromAE()
- AEItems = {}
- local meItems = meAccess.getAvailableItems()
- for _,v in pairs(meItems) do
- AEItems[v["name"]] = v
- end
- end
- function Find_Items(itemSearch)
- if #AEItems == 0 then Load_FromAE() end
- local items = {}
- for _,search in pairs(itemSearch) do
- for k,v in pairs(AEItems) do
- if string.find(k, search) ~= nil then -- or string.find(v["rawName"], search) ~= nil
- items[k] = v
- end
- end
- end
- return items
- end
- function Display_ItemSubset(name, items)
- itemMonitor.setCursorPos(monitorX, monitorY)
- Output(name)
- Output("--------------")
- for k,v in pairs(items) do Output(k.."["..v["qty"].."]") end
- Output("--------------")
- end
- function Output(text)
- monitor_X_Scale = math.max(monitor_X_Scale, #text + 2) -- some padding
- AdvanceMonitorPosition()
- itemMonitor.write(text)
- end
- function AdvanceMonitorPosition()
- monitorY = monitorY + 1
- if monitorY > monitor_MaxY then
- monitorY = monitor_MinY
- monitorX = monitorX + monitor_X_Scale
- end
- itemMonitor.setCursorPos(monitorX, monitorY)
- end
- function Show_Items(items)
- itemMonitor.clear()
- itemMonitor.setTextScale(0.5)
- for k,v in spairs(items, function(t,a,b) return t[b] < t[a] end) do
- itemMonitor.setCursorPos(x,y)
- itemMonitor.write(k.." ["..v.."]")
- y = y + 1
- if y == 51 then
- y = 1
- x = x + 50
- end
- end
- end
- Load_FromAE()
- itemMonitor.clear()
- itemMonitor.setTextScale(.5)
- Display_ItemSubset("Ores", Find_Items(watchItems["ores"]))
- Display_ItemSubset("Ingots", Find_Items(watchItems["ingots"]))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement