Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --need border.lua library for work
- local keyboard=require('keyboard')
- local gpu=require('component').gpu
- local term=require('term')
- local event=require'event'
- local border=require('border')
- local c={
- green=0x00e000,
- light_gray=0x909090,
- gray=0x303030,
- red=0xe00000,
- purple=0xa000a0,
- black=0x0
- }
- local rx,ry=gpu.getResolution()
- gpu.setResolution (80,18)
- function fl()
- local y_pos=2
- local flux_net = border.getDevice('flux')
- local half=gpu.getResolution()/2
- if #flux_net > 0 then
- local name='--FLUX NETWORKS--'
- border.put(name,half-#name/2,y_pos,c.black,c.light_gray)
- y_pos=y_pos+3
- for f in pairs(flux_net) do
- local name=flux_net[f].getNetworkInfo().name
- local energy=flux_net[f].getEnergyInfo()
- local input=" IN: "..border.energyTier(energy.energyInput).." "
- local output=" OUT: "..border.energyTier(energy.energyOutput).." "
- local x=half-(#name+#input+#output+2)/2
- border.put(name,x,y_pos,c.green,c.gray) x=x+#name+2
- border.put (input,x,y_pos,c.green,c.gray) x=x+#input+2
- border.put(output,x,y_pos,c.green,c.gray)--gpu.set(x,2,output)
- y_pos=y_pos+3
- end
- end
- local me=border.getDevice('me_')
- if #me > 0 then
- me=me[1]
- local power=' ME use: ' .. border.energyTier(me.getAvgPowerUsage()) .. ' '
- local stored=' ME power stored: ' .. border.energyTier(me.getStoredPower()) .. ' '
- stored=string.sub(stored,1,#stored-5)
- local xl=half-#power/2-#stored/2
- border.put(power,xl,y_pos,c.green,c.gray)
- border.put(stored,xl+#power+2,y_pos,c.green,c.gray)
- y_pos=y_pos+3
- name='--ME CPUS--'
- border.put(name,half-#name/2,y_pos,c.black,c.light_gray)
- y_pos=y_pos+3
- local cpus=me.getCpus()
- local width=half/2-1 --сколько ЦПУ уместится в ряд минус края
- local state=c.gray
- local cpuX = 0
- for f in pairs(cpus) do
- if cpuX == 0 then
- if #cpus - f + 1 > width then-- за раз не влезет
- cpuX = 1
- else cpuX = width / 2 - (#cpus-f+1)/2 --неполный ряд
- end
- end
- state = cpus[f].busy and c.gray or c.green
- border.put(' ',cpuX*4+2,y_pos,nil,state)
- cpuX = cpuX + 1
- if cpuX == width - 1 then
- cpuX = 0 y_pos = y_pos + 3
- end
- end
- y_pos=y_pos+3
- end
- return true
- end
- local monitoringID=event.timer(0.1,fl,math.huge)
- term.clear()
- while true do --absolutely nothing
- event.pull(1)
- if keyboard.isKeyDown(keyboard.keys.delete) then
- event.cancel(monitoringID)
- monitoringID=nil
- gpu.setResolution(rx,ry)
- term.clear()
- break
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement