Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local bridge = peripheral.find("meBridge")
- if bridge == nil then error("meBridge not found") end
- function wrapPs(peripheralName)
- periTab={}
- sideTab={}
- if peripheralName==nil then
- print("Error")
- end
- local peripherals = peripheral.getNames()
- local i2 = 1
- for i =1, #peripherals do
- if peripheral.getType(peripherals[i])==peripheralName then
- periTab[i2]=peripheral.wrap(peripherals[i])
- sideTab[i2]=peripherals[i]
- i2=i2+1
- end
- end
- if periTab~={} then
- return periTab,sideTab
- else
- return nil
- end
- end
- function CenterT(text, line, txtback , txtcolor, pos)
- if text==nil then
- text="null"
- end
- monX,monY = mon.getSize()
- mon.setBackgroundColor(txtback)
- mon.setTextColor(txtcolor)
- length = string.len(text)
- dif = math.floor(monX-length)
- x = math.floor(dif/2)
- if pos == "head" then
- mon.setCursorPos(x+1, line)
- mon.write(text)
- elseif pos == "left" then
- mon.setCursorPos(2,line)
- mon.write(text)
- elseif pos == "right" then
- mon.setCursorPos(monX-length, line)
- mon.write(text)
- end
- end
- function sort(a,b)
- return a.amount>b.amount
- end
- me = wrapPs("meBridge")[1]
- mon = wrapPs("monitor")[1]
- while true do
- sleep(3)
- local itemcount=0
- local fluidcount=0
- local allitems=me.listItems()
- local allfuilds=me.listFluid()
- for i,v in pairs(allfuilds) do
- fluidcount=fluidcount+v.amount
- end
- for i,v in pairs(allitems) do
- itemcount=itemcount+v.amount
- end
- table.sort(allitems,sort)
- table.sort(allfuilds,sort)
- if #allitems==0 then
- for i=1,10,1 do
- allitems[i]={amount=0,name="minecraft:air",displayName="air",nbt={}}
- end
- end
- if #allfuilds==0 then
- for i=1,10,1 do
- allfuilds[i]={amount=0,name="minecraft:air",displayName="air"}
- end
- end
- mon.clear()
- for i=1,10,1 do
- local v=allitems[i]
- CenterT(v.displayName ,i+6, colors.black, colors.lightGray,"left")
- CenterT(tostring(v.amount) ,i+6, colors.black, colors.lightGray,"right")
- end
- for i=1,10,1 do
- local v=allfuilds[i]
- if v==nil then
- v={}
- v.displayName="air"
- v.amount=0
- end
- CenterT(v.displayName ,i+17, colors.black, colors.lightGray,"left")
- CenterT(tostring(v.amount).."mb" ,i+17, colors.black, colors.lightGray,"right")
- end
- local maxeng=tonumber(me.getMaxEnergyStorage())*2
- local engstor=tonumber(me.getEnergyStorage())*2
- local enguse=tonumber(me.getEnergyUsage())*2
- CenterT("ME Monitor v0.1 by deng" ,1, colors.black, colors.lightGray,"head")
- CenterT("Energy: "..math.floor(engstor/100000)/10 .."MFE/"..math.floor(maxeng/100000)/10 .."MFE" ,2, colors.black, colors.lightBlue,"left")
- CenterT(math.floor(enguse/10)/100 .."KFE/t" ,3, colors.black, colors.lightBlue,"right")
- CenterT("Items: "..itemcount.."/".."??",4,colors.black,colors.white,"left")--me.getMaxItemDiskStorage().." ("..math.floor(((itemcount/me.getMaxItemDiskStorage())*10000)+.5)/100 .."%)",3,colors.black,colors.white,"left")
- CenterT("Fluids: "..fluidcount.."mb/".."??",5, colors.black, colors.blue,"left")--me.getMaxFluidDiskStorage().."mb".." ("..math.floor(((fluidcount/me.getMaxFluidDiskStorage())*10000)+.5)/100 .."%)" ,4, colors.black, colors.blue,"left")
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement