Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local statusChannelID = 5
- -- Find Modem
- local modem = nil
- for sideId, side in ipairs(redstone.getSides()) do
- if peripheral.getType(side) ~= nil then print(side .. ": " .. peripheral.getType(side)) end
- if peripheral.getType(side) == "modem" then
- modem = peripheral.wrap(side);
- end
- end
- if modem == nil then
- error("Could not bind to modem. Is one attached?")
- end
- --if true then return end
- -- Find ME Network Block
- local me = nil
- for sideId, side in ipairs(redstone.getSides()) do
- local ptype = peripheral.getType(side)
- if ptype == "tileinterface" or ptype == "tilecontroller" or ptype == "aemultipart" then
- me = peripheral.wrap(side);
- end
- end
- if me == nil then
- error("Could not bind to ME Interface. Is one attached?")
- end
- term.clear()
- term.setCursorPos(1,1)
- print("ME Status Monitor...")
- print()
- print("Press 'q' to quit")
- local status = {}
- local energyUsage = me.getAvgPowerUsage()
- local pollTimer = os.startTimer(0)
- while true do
- local event, p1, p2, p3, p4 = os.pullEvent()
- if event == "key" then
- if p1 == keys.q then
- term.setCursorPos(1,11)
- return
- end
- elseif event == "timer" and p1 == pollTimer then
- local items = me.getAvailableItems()
- local inv = {}
- inv["Au"] = 0
- inv["Fe"] = 0
- inv["Cu"] = 0
- inv["Sn"] = 0
- inv["Ag"] = 0
- inv["Pb"] = 0
- inv["Sh"] = 0
- inv["Bz"] = 0
- inv["El"] = 0
- inv["Sg"] = 0
- inv["En"] = 0
- inv["Al"] = 0
- inv["RI"] = 0
- inv["EA"] = 0
- inv["VA"] = 0
- inv["Ye"] = 0
- for i, val in ipairs(items) do
- if val.fingerprint.id == "minecraft:gold_ingot" then
- inv["Au"] = val.size
- elseif val.fingerprint.id == "minecraft:iron_ingot" then
- inv["Fe"] = val.size
- elseif val.fingerprint.id == "ThermalFoundation:material" and val.fingerprint.dmg == 64 then
- inv["Cu"] = val.size
- elseif val.fingerprint.id == "ThermalFoundation:material" and val.fingerprint.dmg == 65 then
- inv["Sn"] = val.size
- elseif val.fingerprint.id == "ThermalFoundation:material" and val.fingerprint.dmg == 66 then
- inv["Ag"] = val.size
- elseif val.fingerprint.id == "ThermalFoundation:material" and val.fingerprint.dmg == 67 then
- inv["Pb"] = val.size
- elseif val.fingerprint.id == "ThermalFoundation:material" and val.fingerprint.dmg == 69 then
- inv["Sh"] = val.size
- elseif val.fingerprint.id == "ThermalFoundation:material" and val.fingerprint.dmg == 73 then
- inv["Bz"] = val.size
- elseif val.fingerprint.id == "ThermalFoundation:material" and val.fingerprint.dmg == 71 then
- inv["El"] = val.size
- elseif val.fingerprint.id == "ThermalFoundation:material" and val.fingerprint.dmg == 74 then
- inv["Sg"] = val.size
- elseif val.fingerprint.id == "ThermalFoundation:material" and val.fingerprint.dmg == 76 then
- inv["En"] = val.size
- elseif val.fingerprint.id == "TConstruct:materials" and val.fingerprint.dmg == 11 then
- inv["Al"] = val.size
- elseif val.fingerprint.id == "IC2:itemIngot" and val.fingerprint.dmg == 3 then
- inv["RI"] = val.size
- elseif val.fingerprint.id == "EnderIO:itemAlloy" and val.fingerprint.dmg == 1 then
- inv["EA"] = val.size
- elseif val.fingerprint.id == "EnderIO:itemAlloy" and val.fingerprint.dmg == 2 then
- inv["VA"] = val.size
- elseif val.fingerprint.id == "BigReactors:BRIngot" and val.fingerprint.dmg == 0 then
- inv["Ye"] = val.size
- end
- end
- local data = textutils.serialize(inv)
- energyUsage = me.getAvgPowerUsage()
- status["ME Network Pwr"] = math.floor(energyUsage * 2) .. " RF/t"
- local craftingCPUs = me.getCraftingCPUs()
- status["ME Crafting CPUs"] = #craftingCPUs
- local busyCPUCount = 0
- for cpuId, cpu in ipairs(craftingCPUs) do
- for key, val in pairs(cpu) do
- if key == "busy" and val == true then busyCPUCount = busyCPUCount + 1 end
- end
- end
- status["ME Crafting CPUs Busy"] = busyCPUCount
- status["Inventory"] = inv
- modem.transmit(statusChannelID, 0, textutils.serialize(status))
- pollTimer = os.startTimer(5)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement